musli_core::en

Trait MapEncoder

Source
pub trait MapEncoder {
    type Cx: ?Sized + Context;
    type Ok;
    type EncodeEntry<'this>: EntryEncoder<Cx = Self::Cx, Ok = Self::Ok>
       where Self: 'this;

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

    // Provided methods
    fn encode_entry_fn<F>(
        &mut self,
        f: F,
    ) -> Result<Self::Ok, <Self::Cx as Context>::Error>
       where F: FnOnce(&mut Self::EncodeEntry<'_>) -> Result<(), <Self::Cx as Context>::Error> { ... }
    fn insert_entry<F, S>(
        &mut self,
        key: F,
        value: S,
    ) -> Result<(), <Self::Cx as Context>::Error>
       where Self: Sized,
             F: Encode<<Self::Cx as Context>::Mode>,
             S: Encode<<Self::Cx as Context>::Mode> { ... }
}
Expand description

Encoder for a map.

Required Associated Types§

Source

type Cx: ?Sized + Context

Context associated with the encoder.

Source

type Ok

Result type of the encoder.

Source

type EncodeEntry<'this>: EntryEncoder<Cx = Self::Cx, Ok = Self::Ok> where Self: 'this

Encode the next pair.

Required Methods§

Source

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

Encode the next pair.

Source

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

Finish encoding pairs.

Provided Methods§

Source

fn encode_entry_fn<F>( &mut self, f: F, ) -> Result<Self::Ok, <Self::Cx as Context>::Error>
where F: FnOnce(&mut Self::EncodeEntry<'_>) -> Result<(), <Self::Cx as Context>::Error>,

Simplified encoder for a map entry, which ensures that encoding is always finished.

Source

fn insert_entry<F, S>( &mut self, key: F, value: S, ) -> Result<(), <Self::Cx as Context>::Error>
where Self: Sized, F: Encode<<Self::Cx as Context>::Mode>, S: Encode<<Self::Cx as Context>::Mode>,

Insert a 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§