Skip to content

Commit

Permalink
implement Serialize for Block
Browse files Browse the repository at this point in the history
  • Loading branch information
iFrostizz committed Aug 31, 2024
1 parent cb1705e commit 0b46142
Show file tree
Hide file tree
Showing 2 changed files with 189 additions and 94 deletions.
15 changes: 11 additions & 4 deletions rlp/src/ser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,10 @@ impl<'a> ser::Serializer for &'a mut Serializer {
_variant_index: u32,
variant: &'static str,
) -> Result<Self::Ok, Self::Error> {
self.serialize_str(variant)
if !variant.is_empty() {
self.serialize_str(variant)?
}
Ok(())
}

fn serialize_newtype_struct<T>(
Expand All @@ -218,7 +221,9 @@ impl<'a> ser::Serializer for &'a mut Serializer {
where
T: ?Sized + Serialize,
{
self.serialize_str(variant)?;
if !variant.is_empty() {
self.serialize_str(variant)?;
}
value.serialize(self)
}

Expand Down Expand Up @@ -246,7 +251,9 @@ impl<'a> ser::Serializer for &'a mut Serializer {
variant: &'static str,
len: usize,
) -> Result<Self::SerializeTupleVariant, Self::Error> {
self.serialize_str(variant)?;
if !variant.is_empty() {
self.serialize_str(variant)?;
}
self.serialize_seq(Some(len))
}

Expand Down Expand Up @@ -307,7 +314,7 @@ impl<'a> ser::SerializeTuple for &'a mut Serializer {
}

fn end(self) -> Result<Self::Ok, Self::Error> {
// self.end_list();
// tuples are not treated as "list with known size"
Ok(())
}
}
Expand Down
Loading

0 comments on commit 0b46142

Please sign in to comment.