Skip to content

Commit af2c17f

Browse files
authored
Merge pull request #137 from iamjpotts/20230831-error-debug
Require Debug trait for implementations of Backend::Error attribute of Backend trait
2 parents 07f23d7 + 5874412 commit af2c17f

2 files changed

Lines changed: 11 additions & 3 deletions

File tree

ipfs-api-prelude/src/backend.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use http::{
2020
StatusCode,
2121
};
2222
use serde::Deserialize;
23-
use std::fmt::Display;
23+
use std::fmt::{Debug, Display};
2424
use tokio_util::codec::{Decoder, FramedRead};
2525

2626
cfg_if::cfg_if! {
@@ -46,9 +46,9 @@ pub trait Backend {
4646

4747
cfg_if::cfg_if! {
4848
if #[cfg(feature = "with-send-sync")] {
49-
type Error: Display + From<ApiError> + From<crate::Error> + Send + 'static;
49+
type Error: Display + Debug + From<ApiError> + From<crate::Error> + Send + 'static;
5050
} else {
51-
type Error: Display + From<ApiError> + From<crate::Error> + 'static;
51+
type Error: Display + Debug + From<ApiError> + From<crate::Error> + 'static;
5252
}
5353
}
5454

ipfs-api/tests/test_backend.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
use ipfs_api::IpfsApi;
2+
3+
// If this compiles, the test has passed, as unwrap() requires the Debug trait.
4+
#[allow(unused)]
5+
async fn test_use_client<C: IpfsApi>(client: &C) {
6+
// Validate that all variants of the Backend trait's Error type (Backend::Error) implement the Debug trait.
7+
client.version().await.unwrap();
8+
}

0 commit comments

Comments
 (0)