Struct TaggedEnumAccess

Source
struct TaggedEnumAccess<'der, 'a, 'de> {
    parent: &'der mut Deserializer<'a, 'de>,
    variant: Variant,
    payload_already_consumed: bool,
}
Expand description

EnumAccess + VariantAccess adapter for tagged enums.

deserialize_enum already consumed the outer {u8 variant_tag: payload} map header and the variant tag, resolved the matching Variant from the Sum, and handed both off to us. From here:

  • EnumAccess::variant_seed yields the variant’s serde name (as a borrowed string) to the visitor — serde-derive’s __Field visitor for enums accepts identifiers as strings just like struct-field visitors do.
  • The four VariantAccess methods dispatch on the kind the visitor asks for (which is driven by the Rust declaration, not the wire), and each reads the matching payload shape directly from parent:
    • unit — consume the trailing nil written by the encode-side serialize_unit.
    • newtype — pass the bare inner value through &mut *parent so any nested tagged types still recurse through the wrapper.
    • tuple — read the int-keyed payload map and reuse the TaggedTupleStructAccess buffering machinery; the variant’s payload Product carries the tag/position mapping.
    • struct — read the int-keyed payload map and reuse TaggedProductMapAccess; the variant’s payload Product carries the tag/field-name mapping.

Fields§

§parent: &'der mut Deserializer<'a, 'de>§variant: Variant§payload_already_consumed: bool

Set when deserialize_enum has already drained the wire payload — the only way to land here is the catch-all route, where the payload was discarded with IgnoredAny before visit_enum. The catch-all is always a unit variant per macro validation, so only unit_variant needs to consult this flag.

Trait Implementations§

Source§

impl<'de, 'der, 'a> EnumAccess<'de> for TaggedEnumAccess<'der, 'a, 'de>

Source§

type Error = Error

The error type that can be returned if some error occurs during deserialization.
Source§

type Variant = TaggedEnumAccess<'der, 'a, 'de>

The Visitor that will be used to deserialize the content of the enum variant.
Source§

fn variant_seed<V>( self, seed: V, ) -> Result<(V::Value, Self::Variant), Self::Error>
where V: DeserializeSeed<'de>,

variant is called to identify which variant to deserialize. Read more
Source§

fn variant<V>(self) -> Result<(V, Self::Variant), Self::Error>
where V: Deserialize<'de>,

variant is called to identify which variant to deserialize. Read more
Source§

impl<'de, 'der, 'a> VariantAccess<'de> for TaggedEnumAccess<'der, 'a, 'de>

Source§

type Error = Error

The error type that can be returned if some error occurs during deserialization. Must match the error type of our EnumAccess.
Source§

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

Called when deserializing a variant with no values. Read more
Source§

fn newtype_variant_seed<T>(self, seed: T) -> Result<T::Value, Self::Error>
where T: DeserializeSeed<'de>,

Called when deserializing a variant with a single value. Read more
Source§

fn tuple_variant<V>( self, _len: usize, visitor: V, ) -> Result<V::Value, Self::Error>
where V: Visitor<'de>,

Called when deserializing a tuple-like variant. Read more
Source§

fn struct_variant<V>( self, _fields: &'static [&'static str], visitor: V, ) -> Result<V::Value, Self::Error>
where V: Visitor<'de>,

Called when deserializing a struct-like variant. Read more
Source§

fn newtype_variant<T>(self) -> Result<T, Self::Error>
where T: Deserialize<'de>,

Called when deserializing a variant with a single value. Read more

Auto Trait Implementations§

§

impl<'der, 'a, 'de> Freeze for TaggedEnumAccess<'der, 'a, 'de>

§

impl<'der, 'a, 'de> RefUnwindSafe for TaggedEnumAccess<'der, 'a, 'de>

§

impl<'der, 'a, 'de> Send for TaggedEnumAccess<'der, 'a, 'de>

§

impl<'der, 'a, 'de> Sync for TaggedEnumAccess<'der, 'a, 'de>

§

impl<'der, 'a, 'de> Unpin for TaggedEnumAccess<'der, 'a, 'de>

§

impl<'der, 'a, 'de> !UnwindSafe for TaggedEnumAccess<'der, 'a, 'de>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.