Trait diny_core::backend::Encode [−][src]
pub trait Encode: Sized {
type Format: FormatEncode;
type Data: ?Sized;
fn init(data: &Self::Data) -> Self;
fn poll_encode<W>(
&mut self,
format: &Self::Format,
writer: &mut W,
data: &Self::Data,
cx: &mut Context<'_>
) -> PollEncodeStatus<<<Self as Encode>::Format as Format>::Error>
where
W: AsyncWrite + Unpin;
fn start_encode<W>(
format: &Self::Format,
writer: &mut W,
data: &Self::Data,
cx: &mut Context<'_>
) -> StartEncodeStatus<Self, <<Self as Encode>::Format as Format>::Error>
where
W: AsyncWrite + Unpin,
{ ... }
}
Expand description
Attempt to encode a data structure to an asynchronous writer for a particular format.
Associated Types
type Format: FormatEncode
type Format: FormatEncode
The concrete format to encode with.
Required methods
fn poll_encode<W>(
&mut self,
format: &Self::Format,
writer: &mut W,
data: &Self::Data,
cx: &mut Context<'_>
) -> PollEncodeStatus<<<Self as Encode>::Format as Format>::Error> where
W: AsyncWrite + Unpin,
fn poll_encode<W>(
&mut self,
format: &Self::Format,
writer: &mut W,
data: &Self::Data,
cx: &mut Context<'_>
) -> PollEncodeStatus<<<Self as Encode>::Format as Format>::Error> where
W: AsyncWrite + Unpin,
Provided methods
fn start_encode<W>(
format: &Self::Format,
writer: &mut W,
data: &Self::Data,
cx: &mut Context<'_>
) -> StartEncodeStatus<Self, <<Self as Encode>::Format as Format>::Error> where
W: AsyncWrite + Unpin,
fn start_encode<W>(
format: &Self::Format,
writer: &mut W,
data: &Self::Data,
cx: &mut Context<'_>
) -> StartEncodeStatus<Self, <<Self as Encode>::Format as Format>::Error> where
W: AsyncWrite + Unpin,
Begin encoding bytes for the indicated format to the provided writer.
This is intended to be overriden whenever an optimized code path exists for the (usual) case where enough buffer space is available that the operation will succeed immediately without pending.
Implementation
Implementions must ensure that start_encode
is semantically equivalent to calling
init
followed by poll_encode