Skip to content

Commit

Permalink
impls
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Coats committed Sep 8, 2023
1 parent 0695ddc commit a5ad4dd
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions sdk/src/types/block/output/feature/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,7 @@ pub(crate) mod irc_27 {
}

pub fn to_bytes(&self) -> Vec<u8> {
// Unwrap: Safe because this struct is known to be valid
serde_json::to_string(self).unwrap().into_bytes()
}
}
Expand All @@ -212,6 +213,12 @@ pub(crate) mod irc_27 {
}
}

impl From<Irc27Metadata> for Vec<u8> {
fn from(value: Irc27Metadata) -> Self {
value.to_bytes()
}
}

#[derive(Clone, Debug, Serialize, Deserialize, Getters, PartialEq, Eq)]
#[getset(get = "pub")]
pub struct Attribute {
Expand Down Expand Up @@ -365,6 +372,7 @@ pub(crate) mod irc_30 {
}

pub fn to_bytes(&self) -> Vec<u8> {
// Unwrap: Safe because this struct is known to be valid
serde_json::to_string(self).unwrap().into_bytes()
}
}
Expand All @@ -376,6 +384,12 @@ pub(crate) mod irc_30 {
}
}

impl From<Irc30Metadata> for Vec<u8> {
fn from(value: Irc30Metadata) -> Self {
value.to_bytes()
}
}

#[cfg(test)]
mod test {
use super::*;
Expand Down

0 comments on commit a5ad4dd

Please sign in to comment.