Skip to main content

EntriesDecoder

Trait EntriesDecoder 

Source
pub trait EntriesDecoder<'de> {
    type Cx: Context<Error = Self::Error, Allocator = Self::Allocator>;
    type Error;
    type Allocator: Allocator;
    type Mode: 'static;
    type DecodeEntryKey<'this>: Decoder<'de, Cx = Self::Cx, Error = Self::Error, Allocator = Self::Allocator, Mode = Self::Mode>
       where Self: 'this;
    type DecodeEntryValue<'this>: Decoder<'de, Cx = Self::Cx, Error = Self::Error, Allocator = Self::Allocator, Mode = Self::Mode>
       where Self: 'this;

    // Required methods
    fn cx(&self) -> Self::Cx;
    fn decode_entry_key(
        &mut self,
    ) -> Result<Option<Self::DecodeEntryKey<'_>>, Self::Error>;
    fn decode_entry_value(
        &mut self,
    ) -> Result<Self::DecodeEntryValue<'_>, Self::Error>;
    fn end_entries(self) -> Result<(), Self::Error>;

    // Provided method
    fn size_hint(&self) -> SizeHint { ... }
}
Expand description

Trait governing how to decode a sequence of map pairs.

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

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, Allocator = Self::Allocator>

Context associated with the decoder.

Source

type Error

Error associated with decoding.

Source

type Allocator: Allocator

The allocator associated with the decoder.

Source

type Mode: 'static

The mode of the decoder.

Source

type DecodeEntryKey<'this>: Decoder<'de, Cx = Self::Cx, Error = Self::Error, Allocator = Self::Allocator, Mode = Self::Mode> where Self: 'this

The decoder to use for a tuple field index.

Source

type DecodeEntryValue<'this>: Decoder<'de, Cx = Self::Cx, Error = Self::Error, Allocator = Self::Allocator, Mode = Self::Mode> where Self: 'this

The decoder to use for a tuple field value.

Required Methods§

Source

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

Access the context associated with the decoder.

Source

fn decode_entry_key( &mut self, ) -> Result<Option<Self::DecodeEntryKey<'_>>, Self::Error>

Try to return the decoder for the first value in the pair.

If this is a map the first value would be the key of the map, if this is a struct the first value would be the field of the struct.

Source

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

Decode the value in the map.

Source

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

End entries decoding.

Provided Methods§

Source

fn size_hint(&self) -> SizeHint

Get a size hint for the size of the map being decoded.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§