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§
Sourcetype Format: FormatDecode
type Format: FormatDecode
The concrete format to decode with.
Required Methods§
Sourcefn 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,
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 Methods§
Sourcefn 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,
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.