Skip to main content

EntriesEncoder

Trait EntriesEncoder 

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

    // Required methods
    fn cx(&self) -> Self::Cx;
    fn encode_entry_key(
        &mut self,
    ) -> Result<Self::EncodeEntryKey<'_>, Self::Error>;
    fn encode_entry_value(
        &mut self,
    ) -> Result<Self::EncodeEntryValue<'_>, Self::Error>;
    fn finish_entries(self) -> Result<(), Self::Error>;

    // Provided method
    fn insert_entry<K, V>(
        &mut 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.

This trait exists so that decoders can implement a mode that is compatible with serde serialization.

If you do not intend to implement this, then serde compatibility for your format might be degraded.

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 EncodeEntryKey<'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 EncodeEntryValue<'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_entry_key(&mut self) -> Result<Self::EncodeEntryKey<'_>, Self::Error>

Return the encoder for the key in the entry.

Source

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

Return encoder for value in the entry.

Source

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

Complete encoding map entries.

Provided Methods§

Source

fn insert_entry<K, V>(&mut 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".

Implementors§