musli_core::en

Trait EntriesEncoder

Source
pub trait EntriesEncoder {
    type Cx: ?Sized + Context;
    type Ok;
    type EncodeEntryKey<'this>: Encoder<Cx = Self::Cx, Ok = Self::Ok, Error = <Self::Cx as Context>::Error, Mode = <Self::Cx as Context>::Mode>
       where Self: 'this;
    type EncodeEntryValue<'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_entry_key(
        &mut self,
    ) -> Result<Self::EncodeEntryKey<'_>, <Self::Cx as Context>::Error>;
    fn encode_entry_value(
        &mut self,
    ) -> Result<Self::EncodeEntryValue<'_>, <Self::Cx as Context>::Error>;
    fn finish_entries(self) -> Result<Self::Ok, <Self::Cx as Context>::Error>;

    // Provided method
    fn insert_entry<K, V>(
        &mut self,
        key: K,
        value: V,
    ) -> Result<(), <Self::Cx as Context>::Error>
       where K: Encode<<Self::Cx as Context>::Mode>,
             V: Encode<<Self::Cx as Context>::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: ?Sized + Context

Context associated with the encoder.

Source

type Ok

Result type of the encoder.

Source

type EncodeEntryKey<'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 map encoder to encode the key.

Source

type EncodeEntryValue<'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 map encoder to encode the value.

Required Methods§

Source

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

Return the encoder for the key in the entry.

Source

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

Return encoder for value in the entry.

Source

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

Complete encoding map entries.

Provided Methods§

Source

fn insert_entry<K, V>( &mut self, key: K, value: V, ) -> Result<(), <Self::Cx as Context>::Error>
where K: Encode<<Self::Cx as Context>::Mode>, V: Encode<<Self::Cx as Context>::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§