Trait diny::backend::Decode [−][src]
pub trait Decode {
type Format: FormatDecode;
type Data;
fn init() -> Self;
fn poll_decode<R>(
&mut self,
format: &Self::Format,
reader: &mut R,
cx: &mut Context<'_>
) -> PollDecodeStatus<Self::Data, <Self::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::Format as Format>::Error>
where
R: AsyncBufRead + Unpin,
{ ... }
}
Expand description
Attempt to decode a data structure from an asynchronous reader for a particular format
Associated Types
type Format: FormatDecode
type Format: FormatDecode
The concrete format to decode with.
Required methods
fn poll_decode<R>(
&mut self,
format: &Self::Format,
reader: &mut R,
cx: &mut Context<'_>
) -> PollDecodeStatus<Self::Data, <Self::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::Format as Format>::Error> where
R: AsyncBufRead + Unpin,
Provided methods
fn start_decode<R>(
format: &Self::Format,
reader: &mut R,
cx: &mut Context<'_>
) -> StartDecodeStatus<Self::Data, Self, <Self::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::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