Skip to main content

Decoder

Trait Decoder 

pub trait Decoder<Item, B>
where B: IoBuf,
{ type Error: From<Error>; // Required method fn decode(&mut self, buf: &Slice<B>) -> Result<Item, Self::Error>; }
Available on crate feature io only.
Expand description

Trait for decoding byte sequences back into structured items.

Required Associated Types§

type Error: From<Error>

Errors happened during the decoding process

Required Methods§

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§

§

impl<B> Decoder<Bytes, B> for BytesCodec
where B: IoBuf,

§

type Error = Error

§

impl<T, B> Decoder<T, B> for SerdeJsonCodec
where T: DeserializeOwned, B: IoBuf,