Skip to main content

VariantVisitor

Trait VariantVisitor 

Source
pub trait VariantVisitor<'de> {
    type Output;

    // Required methods
    fn variant_names(&self) -> impl Iterator<Item = &str>;
    fn visit_tag<E>(self, tag: u8) -> Result<Self::Output, E>
       where E: Error;
    fn visit_name<E>(self, name: &str) -> Result<Self::Output, E>
       where E: Error;
}
Expand description

A visitor passed from SumVisitor to SumAccess::variant which the latter uses to decide what variant to deserialize.

Required Associated Types§

Source

type Output

The result of identifying a variant, e.g., some index type.

Required Methods§

Source

fn variant_names(&self) -> impl Iterator<Item = &str>

Provides a list of variant names.

Source

fn visit_tag<E>(self, tag: u8) -> Result<Self::Output, E>
where E: Error,

Identify the variant based on tag.

Source

fn visit_name<E>(self, name: &str) -> Result<Self::Output, E>
where E: Error,

Identify the variant based on name.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementors§