pub struct VariantDecoder<'schema, 'de, R> { /* private fields */ }Expand description
Decodes the fields of a selected enum variant.
Returned by EnumDecoder::decode_variant after reading and validating
the variant tag. Holds the selected schema and the reader positioned at
the variant’s first field. Call variant_name to
inspect its name, then consume the decoder with fields
to lazily decode its fields.
Implementations§
Source§impl<'schema, 'de, R> VariantDecoder<'schema, 'de, R>
impl<'schema, 'de, R> VariantDecoder<'schema, 'de, R>
Sourcepub fn variant_name(&self) -> &'schema str
pub fn variant_name(&self) -> &'schema str
Returns the selected enum variant’s name.
Sourcepub fn fields(self) -> Fields<'schema, 'de, R> ⓘwhere
R: Reader<'de>,
pub fn fields(self) -> Fields<'schema, 'de, R> ⓘwhere
R: Reader<'de>,
Consumes this decoder, creating an iterator that lazily yields the selected variant’s decoded fields in schema order.
Iteration uses the retained reader, continuing after the variant tag
already consumed by EnumDecoder::decode_variant.
Creating the iterator does not read from the input and cannot fail. Each field is decoded as the iterator advances, with decoding errors returned by the corresponding iterator item. Dropping the iterator early leaves the remaining fields unread.