Trait async_codec::Decode [−][src]
pub trait Decode {
type Item;
type Error;
fn decode(
&mut self,
buffer: &mut [u8]
) -> (usize, DecodeResult<Self::Item, Self::Error>);
}
Expand description
Trait for values that can be decoded from a byte buffer
Associated Types
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.
Required methods
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.