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_seedyields the variant’s serde name (as a borrowed string) to the visitor — serde-derive’s__Fieldvisitor for enums accepts identifiers as strings just like struct-field visitors do.- The four
VariantAccessmethods 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 fromparent:- unit — consume the trailing
nilwritten by the encode-sideserialize_unit. - newtype — pass the bare inner value through
&mut *parentso any nested tagged types still recurse through the wrapper. - tuple — read the int-keyed payload map and reuse the
TaggedTupleStructAccessbuffering machinery; the variant’spayloadProductcarries the tag/position mapping. - struct — read the int-keyed payload map and reuse
TaggedProductMapAccess; the variant’spayloadProductcarries the tag/field-name mapping.
- unit — consume the trailing
Fields§
§parent: &'der mut Deserializer<'a, 'de>§variant: Variant§payload_already_consumed: boolSet 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>
impl<'de, 'der, 'a> EnumAccess<'de> for TaggedEnumAccess<'der, 'a, 'de>
Source§type Error = Error
type Error = Error
The error type that can be returned if some error occurs during
deserialization.
Source§type Variant = TaggedEnumAccess<'der, 'a, 'de>
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>,
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 moreSource§impl<'de, 'der, 'a> VariantAccess<'de> for TaggedEnumAccess<'der, 'a, 'de>
impl<'de, 'der, 'a> VariantAccess<'de> for TaggedEnumAccess<'der, 'a, 'de>
Source§type Error = Error
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>
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>,
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>,
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>,
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>,
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more