musli_core::de

Trait SequenceDecoder

Source
pub trait SequenceDecoder<'de> {
    type Cx: ?Sized + Context;
    type DecodeNext<'this>: Decoder<'de, Cx = Self::Cx, Error = <Self::Cx as Context>::Error, Mode = <Self::Cx as Context>::Mode>
       where Self: 'this;

    // Required methods
    fn decode_next(
        &mut self,
    ) -> Result<Self::DecodeNext<'_>, <Self::Cx as Context>::Error>;
    fn try_decode_next(
        &mut self,
    ) -> Result<Option<Self::DecodeNext<'_>>, <Self::Cx as Context>::Error>;

    // Provided methods
    fn size_hint(&self) -> SizeHint { ... }
    fn next<T>(&mut self) -> Result<T, <Self::Cx as Context>::Error>
       where T: Decode<'de, <Self::Cx as Context>::Mode> { ... }
    fn try_next<T>(&mut self) -> Result<Option<T>, <Self::Cx as Context>::Error>
       where T: Decode<'de, <Self::Cx as Context>::Mode> { ... }
}
Expand description

Trait governing how to decode a sequence.

Required Associated Types§

Source

type Cx: ?Sized + Context

Context associated with the decoder.

Source

type DecodeNext<'this>: Decoder<'de, Cx = Self::Cx, Error = <Self::Cx as Context>::Error, Mode = <Self::Cx as Context>::Mode> where Self: 'this

The decoder for individual items.

Required Methods§

Source

fn decode_next( &mut self, ) -> Result<Self::DecodeNext<'_>, <Self::Cx as Context>::Error>

Return decoder to decode the next element.

This will error or provide garbled data in case the next element is not available.

Source

fn try_decode_next( &mut self, ) -> Result<Option<Self::DecodeNext<'_>>, <Self::Cx as Context>::Error>

Try to decode the next element.

Provided Methods§

Source

fn size_hint(&self) -> SizeHint

Get a size hint of known remaining elements.

Source

fn next<T>(&mut self) -> Result<T, <Self::Cx as Context>::Error>
where T: Decode<'de, <Self::Cx as Context>::Mode>,

Decode the next element of the given type, erroring in case it’s absent.

Source

fn try_next<T>(&mut self) -> Result<Option<T>, <Self::Cx as Context>::Error>
where T: Decode<'de, <Self::Cx as Context>::Mode>,

Decode the next element of the given type.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§