EntryEncoder

Trait EntryEncoder 

Source
pub trait EntryEncoder: Sized {
    type Cx: Context<Error = Self::Error>;
    type Error;
    type Mode: 'static;
    type EncodeKey<'this>: Encoder<Cx = Self::Cx, Error = Self::Error, Mode = Self::Mode>
       where Self: 'this;
    type EncodeValue<'this>: Encoder<Cx = Self::Cx, Error = Self::Error, Mode = Self::Mode>
       where Self: 'this;

    // Required methods
    fn cx(&self) -> Self::Cx;
    fn encode_key(&mut self) -> Result<Self::EncodeKey<'_>, Self::Error>;
    fn encode_value(&mut self) -> Result<Self::EncodeValue<'_>, Self::Error>;
    fn finish_entry(self) -> Result<(), Self::Error>;

    // Provided method
    fn insert_entry<K, V>(self, key: K, value: V) -> Result<(), Self::Error>
       where K: Encode<Self::Mode>,
             V: Encode<Self::Mode> { ... }
}
Expand description

Trait governing how to encode a map entry.

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 EncodeKey<'this>: Encoder<Cx = Self::Cx, Error = Self::Error, Mode = Self::Mode> where Self: 'this

The encoder returned when advancing the map encoder to encode the key.

Source

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

The encoder returned when advancing the map encoder to encode the value.

Required Methods§

Source

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

Access the context associated with the encoder.

Source

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

Return the encoder for the key in the entry.

Source

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

Return encoder for value in the entry.

Source

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

Stop encoding this pair.

Provided Methods§

Source

fn insert_entry<K, V>(self, key: K, value: V) -> Result<(), Self::Error>
where K: Encode<Self::Mode>, V: Encode<Self::Mode>,

Insert the pair immediately.

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§