Skip to main content

Decoder

Trait Decoder 

Source
pub trait Decoder<Item, B: IoBuf> {
    type Error: From<Error>;

    // Required method
    fn decode(&mut self, buf: &Slice<B>) -> Result<Item, Self::Error>;
}
Expand description

Trait for decoding byte sequences back into structured items.

Required Associated Types§

Source

type Error: From<Error>

Errors happened during the decoding process

Required Methods§

Source

fn decode(&mut self, buf: &Slice<B>) -> Result<Item, Self::Error>

Decodes a byte sequence into an item.

The given buf is a sliced view into the underlying buffer, which gives one complete frame. Slice implements IoBuf.

You may escape the view by calling Slice::as_inner.

Implementors§