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

The concrete format to encode with.

The concrete data structure to encode.

Required methods

Initialize the internal state of the encoder.

Continue a pending Encode operation.

Provided methods

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

Implementors