Trait fadroma::bin_serde::FadromaSerialize
source · pub trait FadromaSerialize {
// Required methods
fn size_hint(&self) -> usize;
fn to_bytes(&self, ser: &mut Serializer) -> Result<()>;
}
Expand description
A type that knows how to serialize itself to bytes. Can be derived.
Required Methods§
sourcefn size_hint(&self) -> usize
fn size_hint(&self) -> usize
The size in bytes of the particular instance when converted to its byte respresentation. While it’s preferred that this method returns an exact size (or at least a bigger estimation) it’s not an error to return an incorrect number. The penalty for doing so is potentially incurring unnecessary re-allocations.
sourcefn to_bytes(&self, ser: &mut Serializer) -> Result<()>
fn to_bytes(&self, ser: &mut Serializer) -> Result<()>
Serialize the instance into bytes by writing to
the provided Serializer
.