Skip to content

Commit 0abf78f

Browse files
authored
Merge branch 'dev' into issue-357-rate-limit-in-tests
2 parents cdd8b30 + 7e224bf commit 0abf78f

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

primitives/src/ipfs.rs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,21 @@ const URL_PREFIX: &str = "ipfs://";
77

88
pub use cid::{Cid, Error};
99

10-
#[derive(Clone, Serialize, Deserialize, Eq, PartialEq)]
10+
#[derive(Hash, Clone, Serialize, Deserialize, Eq, PartialEq)]
1111
#[serde(try_from = "String", into = "String")]
1212
pub struct IPFS(pub cid::Cid);
1313

14+
impl slog::Value for IPFS {
15+
fn serialize(
16+
&self,
17+
_record: &slog::Record<'_>,
18+
key: slog::Key,
19+
serializer: &mut dyn slog::Serializer,
20+
) -> slog::Result {
21+
serializer.emit_str(key, &self.0.to_string())
22+
}
23+
}
24+
1425
impl fmt::Debug for IPFS {
1526
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
1627
write!(f, "IPFS({})", self.0.to_string())
@@ -31,6 +42,12 @@ impl FromStr for IPFS {
3142
}
3243
}
3344

45+
impl AsRef<IPFS> for IPFS {
46+
fn as_ref(&self) -> &IPFS {
47+
&self
48+
}
49+
}
50+
3451
impl Into<String> for IPFS {
3552
fn into(self) -> String {
3653
self.0.into()

0 commit comments

Comments
 (0)