Skip to main content

VariantDecoder

Struct VariantDecoder 

Source
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>

Source

pub fn variant_name(&self) -> &'schema str

Returns the selected enum variant’s name.

Source

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.

Trait Implementations§

Source§

impl<'schema, 'de, R: Debug> Debug for VariantDecoder<'schema, 'de, R>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'schema, 'de, R> IntoIterator for VariantDecoder<'schema, 'de, R>
where R: Reader<'de>,

Source§

type Item = Result<Field<'schema, 'de>, ReadError>

The type of the elements being iterated over.
Source§

type IntoIter = Fields<'schema, 'de, R>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more

Auto Trait Implementations§

§

impl<'schema, 'de, R> Freeze for VariantDecoder<'schema, 'de, R>
where R: Freeze,

§

impl<'schema, 'de, R> RefUnwindSafe for VariantDecoder<'schema, 'de, R>
where R: RefUnwindSafe,

§

impl<'schema, 'de, R> Send for VariantDecoder<'schema, 'de, R>
where R: Send,

§

impl<'schema, 'de, R> Sync for VariantDecoder<'schema, 'de, R>
where R: Sync,

§

impl<'schema, 'de, R> Unpin for VariantDecoder<'schema, 'de, R>
where R: Unpin,

§

impl<'schema, 'de, R> UnsafeUnpin for VariantDecoder<'schema, 'de, R>
where R: UnsafeUnpin,

§

impl<'schema, 'de, R> UnwindSafe for VariantDecoder<'schema, 'de, R>
where R: UnwindSafe,

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.