Skip to main content

Encoder

Trait Encoder 

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

    // Required method
    fn encode(&mut self, item: Item, buf: &mut B) -> 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 B) -> Result<(), Self::Error>

Encodes an item into bytes.

The buf is guaranteed to have 0 initialized bytes (buf_len() == 0). If the function is returned successfully, all initialized bytes will be treated as valid content to be transmitted.

Implementors§