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§

source

fn serialize<W: Write>(&self, codec: &mut Codec<W>) -> Result<(), WriteError>

Provided Methods§

source

fn serialized_size(&self) -> usize

Default implementation, not efficient, not recommended to use it

source

fn serialize_as_vec(&self) -> Result<Vec<u8>, WriteError>

Convenience method to serialize into a byte vector.

Implementations on Foreign Types§

source§

impl<const N: usize> Serialize for [u8; N]

source§

fn serialize<W: Write>(&self, codec: &mut Codec<W>) -> Result<(), WriteError>

source§

fn serialized_size(&self) -> usize

source§

impl<T: Serialize> Serialize for &T

source§

fn serialize<W: Write>(&self, codec: &mut Codec<W>) -> Result<(), WriteError>

Implementors§