VariantDecoder

Trait VariantDecoder 

Source
pub trait VariantDecoder<'de> {
    type Cx: Context<Error = Self::Error, Allocator = Self::Allocator>;
    type Error;
    type Allocator: Allocator;
    type Mode: 'static;
    type DecodeTag<'this>: Decoder<'de, Cx = Self::Cx, Error = Self::Error, Allocator = Self::Allocator, Mode = Self::Mode>
       where Self: 'this;
    type DecodeValue<'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_tag(&mut self) -> Result<Self::DecodeTag<'_>, Self::Error>;
    fn decode_value(&mut self) -> Result<Self::DecodeValue<'_>, Self::Error>;
}
Expand description

Trait governing how to decode a variant.

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 DecodeTag<'this>: Decoder<'de, Cx = Self::Cx, Error = Self::Error, Allocator = Self::Allocator, Mode = Self::Mode> where Self: 'this

The decoder to use for the variant tag.

Source

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

The decoder to use for the variant value.

Required Methods§

Source

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

Access the context associated with the decoder.

Source

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

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

Decode the second value in the pair..

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§