Skip to main content

EnumDecoder

Struct EnumDecoder 

Source
pub struct EnumDecoder<'schema> { /* private fields */ }
Expand description

Decodes enum payloads using borrowed variant schemas.

Obtained from Decoder::Enum. Call decode_variant to read a payload’s variant tag and obtain a VariantDecoder for inspecting its name and lazily decoding its fields.

Implementations§

Source§

impl<'schema> EnumDecoder<'schema>

Source

pub fn decode_variant<'de, R: Reader<'de>>( &self, reader: R, ) -> ReadResult<VariantDecoder<'schema, 'de, R>>

Reads an enum payload’s variant tag and returns a decoder for that variant.

The reader must supply an encoded enum value matching this decoder’s schema, positioned at its variant tag. The returned VariantDecoder exposes the variant’s name and retains the reader positioned at its fields, which are decoded lazily by VariantDecoder::fields.

§Errors

Returns an error if the tag cannot be read or does not identify a variant in the schema.

Trait Implementations§

Source§

impl<'schema> Debug for EnumDecoder<'schema>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'schema> Freeze for EnumDecoder<'schema>

§

impl<'schema> RefUnwindSafe for EnumDecoder<'schema>

§

impl<'schema> Send for EnumDecoder<'schema>

§

impl<'schema> Sync for EnumDecoder<'schema>

§

impl<'schema> Unpin for EnumDecoder<'schema>

§

impl<'schema> UnsafeUnpin for EnumDecoder<'schema>

§

impl<'schema> UnwindSafe for EnumDecoder<'schema>

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.