Decode

Trait Decode 

Source
pub trait Decode: Sized {
    type Format: FormatDecode;
    type Data;

    // Required methods
    fn init() -> Self;
    fn poll_decode<R>(
        &mut self,
        format: &Self::Format,
        reader: &mut R,
        cx: &mut Context<'_>,
    ) -> PollDecodeStatus<Self::Data, <<Self as Decode>::Format as Format>::Error>
       where R: AsyncBufRead + Unpin;

    // Provided method
    fn start_decode<R>(
        format: &Self::Format,
        reader: &mut R,
        cx: &mut Context<'_>,
    ) -> StartDecodeStatus<Self::Data, Self, <<Self as Decode>::Format as Format>::Error>
       where R: AsyncBufRead + Unpin { ... }
}
Expand description

Attempt to decode a data structure from an asynchronous reader for a particular format

Required Associated Types§

Source

type Format: FormatDecode

The concrete format to decode with.

Source

type Data

The concrete data structure to decode.

Required Methods§

Source

fn init() -> Self

Initialize the internal state of the decoder.

Source

fn poll_decode<R>( &mut self, format: &Self::Format, reader: &mut R, cx: &mut Context<'_>, ) -> PollDecodeStatus<Self::Data, <<Self as Decode>::Format as Format>::Error>
where R: AsyncBufRead + Unpin,

Continue a pending Decode operation.

Provided Methods§

Source

fn start_decode<R>( format: &Self::Format, reader: &mut R, cx: &mut Context<'_>, ) -> StartDecodeStatus<Self::Data, Self, <<Self as Decode>::Format as Format>::Error>
where R: AsyncBufRead + Unpin,

Begin decoding bytes for the indicated format from the provided reader.

This is intended to be overriden whenever an optimized code path exists for the (usual) case where enough bytes have been buffered into the reader that the operation will succeed immediately without pending.

§Implementation

Implementions must ensure that start_decode is semantically equivalent to calling init followed by poll_decode

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§