Skip to content

Commit 7e224bf

Browse files
authored
Merge pull request #378 from AdExNetwork/ipfs-slog-value-impl
primitives - IPFS - impl slog::Value for usage with slog
2 parents 0a800ca + 448af1b commit 7e224bf

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

primitives/src/ipfs.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,17 @@ pub use cid::{Cid, Error};
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)