musli_core::en

Trait SequenceEncoder

Source
pub trait SequenceEncoder {
    type Cx: ?Sized + Context;
    type Ok;
    type EncodeNext<'this>: Encoder<Cx = Self::Cx, Ok = Self::Ok, Error = <Self::Cx as Context>::Error, Mode = <Self::Cx as Context>::Mode>
       where Self: 'this;

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

    // Provided method
    fn push<T>(&mut self, value: T) -> Result<(), <Self::Cx as Context>::Error>
       where T: Encode<<Self::Cx as Context>::Mode> { ... }
}
Expand description

Trait governing how to encode a sequence.

Required Associated Types§

Source

type Cx: ?Sized + Context

Context associated with the encoder.

Source

type Ok

Result type of the encoder.

Source

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

The encoder returned when advancing the sequence encoder.

Required Methods§

Source

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

Return encoder for the next element.

Source

fn finish_sequence(self) -> Result<Self::Ok, <Self::Cx as Context>::Error>

Finish encoding the sequence.

Provided Methods§

Source

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

Push an element into the sequence.

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§