pub trait SumVisitor<'de> {
    type Output;

    // Required methods
    fn sum_name(&self) -> Option<&str>;
    fn visit_sum<A: SumAccess<'de>>(
        self,
        data: A
    ) -> Result<Self::Output, A::Error>;

    // Provided method
    fn is_option(&self) -> bool { ... }
}
Expand description

A visitor walking through a Deserializer for sums.

This side is provided by a Deserialize implementation when calling Deserializer::deserialize_sum.

Required Associated Types§

source

type Output

The resulting sum.

Required Methods§

source

fn sum_name(&self) -> Option<&str>

Returns the name of the sum, if any.

source

fn visit_sum<A: SumAccess<'de>>(self, data: A) -> Result<Self::Output, A::Error>

Drives the deserialization of a sum value.

This method will ask the data format (A: SumAccess) which variant of the sum to select in terms of a variant name / tag. A will use a VariantVisitor, that SumVisitor has provided, to translate into something that is meaningful for visit_sum, e.g., an index.

The data format will also return an object (VariantAccess) that can deserialize the contents of the variant.

Provided Methods§

source

fn is_option(&self) -> bool

Returns whether an option is expected.

The provided implementation does not.

Object Safety§

This trait is not object safe.

Implementors§