MapEncoder

Trait MapEncoder 

Source
pub trait MapEncoder {
    type Cx: Context<Error = Self::Error>;
    type Error;
    type Mode: 'static;
    type EncodeEntry<'this>: EntryEncoder<Cx = Self::Cx, Error = Self::Error, Mode = Self::Mode>
       where Self: 'this;

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

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

Encoder for a map.

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

Encode the next pair.

Required Methods§

Source

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

Access the context associated with the encoder.

Source

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

Encode the next map entry.

Source

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

Finish encoding a map.

Provided Methods§

Source

fn encode_entry_fn<F>(&mut self, f: F) -> Result<(), Self::Error>
where F: FnOnce(&mut Self::EncodeEntry<'_>) -> Result<(), Self::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::Error>
where F: Encode<Self::Mode>, S: Encode<Self::Mode>,

Insert a map entry.

Source

fn as_encoder(&mut self) -> AsEncoder<'_, Self>
where Self: Sized,

Encode a map entry.

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§