From a5ad4dd08377c3ac06f451f451f333e4cebc9e5f Mon Sep 17 00:00:00 2001 From: Alex Coats Date: Fri, 8 Sep 2023 09:11:56 -0400 Subject: [PATCH] impls --- sdk/src/types/block/output/feature/metadata.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/sdk/src/types/block/output/feature/metadata.rs b/sdk/src/types/block/output/feature/metadata.rs index d94583ba98..eaebb7f72f 100644 --- a/sdk/src/types/block/output/feature/metadata.rs +++ b/sdk/src/types/block/output/feature/metadata.rs @@ -201,6 +201,7 @@ pub(crate) mod irc_27 { } pub fn to_bytes(&self) -> Vec { + // Unwrap: Safe because this struct is known to be valid serde_json::to_string(self).unwrap().into_bytes() } } @@ -212,6 +213,12 @@ pub(crate) mod irc_27 { } } + impl From for Vec { + fn from(value: Irc27Metadata) -> Self { + value.to_bytes() + } + } + #[derive(Clone, Debug, Serialize, Deserialize, Getters, PartialEq, Eq)] #[getset(get = "pub")] pub struct Attribute { @@ -365,6 +372,7 @@ pub(crate) mod irc_30 { } pub fn to_bytes(&self) -> Vec { + // Unwrap: Safe because this struct is known to be valid serde_json::to_string(self).unwrap().into_bytes() } } @@ -376,6 +384,12 @@ pub(crate) mod irc_30 { } } + impl From for Vec { + fn from(value: Irc30Metadata) -> Self { + value.to_bytes() + } + } + #[cfg(test)] mod test { use super::*;