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>
impl<'schema> EnumDecoder<'schema>
Sourcepub fn decode_variant<'de, R: Reader<'de>>(
&self,
reader: R,
) -> ReadResult<VariantDecoder<'schema, 'de, R>>
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§
Auto Trait Implementations§
impl<'schema> Forget for EnumDecoder<'schema>
impl<'schema> Freeze for EnumDecoder<'schema>
impl<'schema> Move 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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more