[][src]Trait async_codec::Decode

pub trait Decode {
    type Item;
    type Error;
    fn decode(
        &mut self,
        buffer: &mut [u8]
    ) -> (usize, DecodeResult<Self::Item, Self::Error>); }

Trait for values that can be decoded from a byte buffer

Associated Types

type Item

The item being decoded

type Error

The error that may arise from a decode operation

Note that this should not be returned in the event of an unexpected end-of-buffer. Instead, a DecodeResult::UnexpectedEnd should be used.

Loading content...

Required methods

fn decode(
    &mut self,
    buffer: &mut [u8]
) -> (usize, DecodeResult<Self::Item, Self::Error>)

Attempt to decode a value from the buffer

Returns the number of bytes consumed from the buffer, along with a DecodeResult with either an item, error, or "need more bytes."

Note that the "bytes consumed" return value should only be non-zero if either the buffer contains a full frame, or if internal buffering is employed.

Loading content...

Implementors

Loading content...