Trait Encoder

Source
pub trait Encoder<Item> {
    type Error: From<Error>;

    // Required method
    fn encode(
        &mut self,
        item: Item,
        buf: &mut Vec<u8>,
    ) -> Result<(), Self::Error>;
}
Expand description

Trait for types that encode values into bytes.

Required Associated Types§

Source

type Error: From<Error>

The error type that can be returned during encoding operations.

Required Methods§

Source

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

Encodes an item into bytes.

Returns the number of bytes written to the buffer.

Implementors§