Skip to main content

SequenceDecoder

Trait SequenceDecoder 

Source
pub trait SequenceDecoder<'de> {
    type Cx: Context<Error = Self::Error, Allocator = Self::Allocator>;
    type Error;
    type Allocator: Allocator;
    type Mode: 'static;
    type DecodeNext<'this>: Decoder<'de, Cx = Self::Cx, Error = Self::Error, Allocator = Self::Allocator, Mode = Self::Mode>
       where Self: 'this;

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

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

Trait governing how to decode a sequence.

Required Associated Types§

Source

type Cx: Context<Error = Self::Error, Allocator = Self::Allocator>

Context associated with the decoder.

Source

type Error

Error associated with decoding.

Source

type Allocator: Allocator

The allocator associated with the decoder.

Source

type Mode: 'static

The mode of the decoder.

Source

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

The decoder for individual items.

Required Methods§

Source

fn cx(&self) -> Self::Cx

Access the context associated with the decoder.

Source

fn decode_next(&mut self) -> Result<Self::DecodeNext<'_>, Self::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::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::Error>
where T: Decode<'de, Self::Mode, Self::Allocator>,

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::Error>
where T: Decode<'de, Self::Mode, Self::Allocator>,

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".

Implementors§