[][src]Trait ntex_codec::Decoder

pub trait Decoder {
    type Item;
    type Error: Debug;
    fn decode(
        &mut self,
        src: &mut BytesMut
    ) -> Result<Option<Self::Item>, Self::Error>; fn decode_eof(
        &mut self,
        buf: &mut BytesMut
    ) -> Result<Option<Self::Item>, Self::Error> { ... } }

Decoding of frames via buffers.

Associated Types

type Item

The type of decoded frames.

type Error: Debug

The type of unrecoverable frame decoding errors.

If an individual message is ill-formed but can be ignored without interfering with the processing of future messages, it may be more useful to report the failure as an Item.

Loading content...

Required methods

fn decode(
    &mut self,
    src: &mut BytesMut
) -> Result<Option<Self::Item>, Self::Error>

Attempts to decode a frame from the provided buffer of bytes.

Loading content...

Provided methods

fn decode_eof(
    &mut self,
    buf: &mut BytesMut
) -> Result<Option<Self::Item>, Self::Error>

A default method available to be called when there are no more bytes available to be read from the underlying I/O.

This method defaults to calling decode and returns an error if Ok(None) is returned while there is unconsumed data in buf. Typically this doesn't need to be implemented unless the framing protocol differs near the end of the stream.

Loading content...

Implementors

impl Decoder for BytesCodec[src]

type Item = BytesMut

type Error = Error

Loading content...