SequenceEncoder

Trait SequenceEncoder 

Source
pub trait SequenceEncoder {
    type Cx: Context<Error = Self::Error>;
    type Error;
    type Mode: 'static;
    type EncodeNext<'this>: Encoder<Cx = Self::Cx, Error = Self::Error, Mode = Self::Mode>
       where Self: 'this;

    // Required methods
    fn cx(&self) -> Self::Cx;
    fn encode_next(&mut self) -> Result<Self::EncodeNext<'_>, Self::Error>;
    fn finish_sequence(self) -> Result<(), Self::Error>;

    // Provided methods
    fn push<T>(&mut self, value: T) -> Result<(), Self::Error>
       where T: Encode<Self::Mode> { ... }
    fn encode_slice<T>(
        &mut self,
        slice: impl AsRef<[T]>,
    ) -> Result<(), Self::Error>
       where T: Encode<Self::Mode> { ... }
    fn encode_slices<T>(
        &mut self,
        slices: impl IntoIterator<Item: AsRef<[T]>>,
    ) -> Result<(), Self::Error>
       where T: Encode<Self::Mode> { ... }
}
Expand description

Trait governing how to encode a sequence.

Required Associated Types§

Source

type Cx: Context<Error = Self::Error>

Context associated with the encoder.

Source

type Error

Error associated with encoding.

Source

type Mode: 'static

The mode of the encoder.

Source

type EncodeNext<'this>: Encoder<Cx = Self::Cx, Error = Self::Error, Mode = Self::Mode> where Self: 'this

The encoder returned when advancing the sequence encoder.

Required Methods§

Source

fn cx(&self) -> Self::Cx

Access the associated context.

Source

fn encode_next(&mut self) -> Result<Self::EncodeNext<'_>, Self::Error>

Return encoder for the next element.

Source

fn finish_sequence(self) -> Result<(), Self::Error>

Finish encoding the sequence.

Provided Methods§

Source

fn push<T>(&mut self, value: T) -> Result<(), Self::Error>
where T: Encode<Self::Mode>,

Push an element into the sequence.

Source

fn encode_slice<T>(&mut self, slice: impl AsRef<[T]>) -> Result<(), Self::Error>
where T: Encode<Self::Mode>,

Encode a slice of values.

This can be called multiple types and has the same effect as calling push for each value.

Source

fn encode_slices<T>( &mut self, slices: impl IntoIterator<Item: AsRef<[T]>>, ) -> Result<(), Self::Error>
where T: Encode<Self::Mode>,

Encode an iterator of contiguous slices of values.

This can be called multiple types and has the same effect as calling push for each value.

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§