pub trait Serialize {
// Required method
fn serialize<W: Write>(
&self,
codec: &mut Codec<W>
) -> Result<(), WriteError>;
// Provided methods
fn serialized_size(&self) -> usize { ... }
fn serialize_as_vec(&self) -> Result<Vec<u8>, WriteError> { ... }
}
Expand description
Define that an object can be written to an std::io::Write
object.
Required Methods§
Provided Methods§
sourcefn serialized_size(&self) -> usize
fn serialized_size(&self) -> usize
Default implementation, not efficient, not recommended to use it
sourcefn serialize_as_vec(&self) -> Result<Vec<u8>, WriteError>
fn serialize_as_vec(&self) -> Result<Vec<u8>, WriteError>
Convenience method to serialize into a byte vector.