Trait Encoder

Source
pub trait Encoder {
    type Item;
    type Error;

    // Required method
    fn encode(
        &mut self,
        item: Self::Item,
        buf: &mut Vec<u8>,
    ) -> Result<(), Self::Error>;
}
Available on crate feature alloc only.
Expand description

Encode an item into a buffer of bytes.

Required Associated Types§

Source

type Item

The type of items the encoder accepts.

Source

type Error

Error type returned by the encoder.

Required Methods§

Source

fn encode( &mut self, item: Self::Item, buf: &mut Vec<u8>, ) -> Result<(), Self::Error>

Encode item into buf.

Implementations should only append data to buf. Additionally, it is not guaranteed that buf is empty on each call of this method.

Implementors§