Skip to main content

DecoderExt

Trait DecoderExt 

Source
pub trait DecoderExt<'de> {
    // Required methods
    fn take_slot<T>(&mut self) -> Result<Slot<'de, T>, DecodeError>;
    fn take_slice_slot<T>(
        &mut self,
        len: usize,
    ) -> Result<Slot<'de, [T]>, DecodeError>;
    fn decode_prefix<T>(&mut self) -> Result<T, DecodeError>
       where T: Decode<Self, Constraint = ()>;
    fn decode_prefix_with_constraint<T>(
        &mut self,
        constraint: T::Constraint,
    ) -> Result<T, DecodeError>
       where T: Decode<Self>;
    fn decode<T>(&mut self) -> Result<T, DecodeError>
       where T: Decode<Self, Constraint = ()>;
    fn decode_with_constraint<T>(
        &mut self,
        constraint: T::Constraint,
    ) -> Result<T, DecodeError>
       where T: Decode<Self>;
}
Expand description

Extension methods for Decoder.

Required Methods§

Source

fn take_slot<T>(&mut self) -> Result<Slot<'de, T>, DecodeError>

Takes enough chunks for a T, returning a Slot of the taken value.

Source

fn take_slice_slot<T>( &mut self, len: usize, ) -> Result<Slot<'de, [T]>, DecodeError>

Takes enough chunks for a slice of T, returning a Slot of the taken slice.

Source

fn decode_prefix<T>(&mut self) -> Result<T, DecodeError>
where T: Decode<Self, Constraint = ()>,

Decodes an owned value from the decoder without finishing it.

On success, returns Ok of an owned value. Returns Err if decoding failed.

Source

fn decode_prefix_with_constraint<T>( &mut self, constraint: T::Constraint, ) -> Result<T, DecodeError>
where T: Decode<Self>,

Decodes an owned value from the decoder with some constraint without finishing it.

On success, returns Ok of an owned value. Returns Err if decoding failed.

Source

fn decode<T>(&mut self) -> Result<T, DecodeError>
where T: Decode<Self, Constraint = ()>,

Decodes an owned value from the decoder and finishes it.

On success, returns Ok of an owned value. Returns Err if decoding failed.

Source

fn decode_with_constraint<T>( &mut self, constraint: T::Constraint, ) -> Result<T, DecodeError>
where T: Decode<Self>,

Decodes an owned value from the decoder with some constraint and finishes it.

On success, returns Ok of an owned value. Returns Err if decoding failed.

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§

Source§

impl<'de, D: Decoder<'de> + ?Sized> DecoderExt<'de> for D