Skip to main content

DecoderImpl

Struct DecoderImpl 

Source
pub struct DecoderImpl<R, C: Config, Context> { /* private fields */ }
Expand description

A Decoder that reads bytes from a given reader R.

This struct should rarely be used. In most cases, prefer any of the decode functions.

The ByteOrder that is chosen will impact the endianness that is used to read integers out of the reader.

use bincode_next::de::Decode;
use bincode_next::de::DecoderImpl;
let mut context = ();
let mut decoder = DecoderImpl::new(some_reader, bincode_next::config::standard(), &mut context);
// this u32 can be any Decode
let value = u32::decode(&mut decoder).unwrap();

Implementations§

Source§

impl<R: Reader, C: Config, Context> DecoderImpl<R, C, Context>

Source

pub const fn new(reader: R, config: C, context: Context) -> Self

Construct a new Decoder

Trait Implementations§

Source§

impl<'de, R: BorrowReader<'de>, C: Config, Context> BorrowDecoder<'de> for DecoderImpl<R, C, Context>

Source§

type BR = R

The concrete [BorrowReader] type
Source§

fn borrow_reader(&mut self) -> &mut Self::BR

Returns a mutable reference to the borrow reader
Source§

impl<R: Reader, C: Config, Context> Decoder for DecoderImpl<R, C, Context>

Source§

type C = C

The concrete Config type
Source§

type Context = Context

The decoding context type
Source§

type R = R

The concrete Reader type
Source§

fn reader(&mut self) -> &mut Self::R

Returns a mutable reference to the reader
Source§

fn config(&self) -> &Self::C

Returns a reference to the config
Source§

fn claim_bytes_read(&mut self, n: usize) -> Result<(), DecodeError>

Claim that n bytes are going to be read from the decoder. This can be used to validate Configuration::Limit<N>(). Read more
Source§

fn unclaim_bytes_read(&mut self, n: usize)

Notify the decoder that n bytes are being reclaimed. Read more
Source§

fn context(&mut self) -> &mut Self::Context

Returns the decoding context
Source§

fn with_context<C>(&mut self, context: C) -> WithContext<'_, Self, C>

Wraps decoder with a context
Source§

fn claim_container_read<T>(&mut self, len: usize) -> Result<(), DecodeError>

Claim that we’re going to read a container which contains len entries of T. This will correctly handle overflowing if len * size_of::<T>() > usize::max_value Read more
Source§

fn decode_u8(&mut self) -> Result<u8, DecodeError>

Decode a u8 value. Read more
Source§

fn decode_u16(&mut self) -> Result<u16, DecodeError>

Decode a u16 value. Read more
Source§

fn decode_u32(&mut self) -> Result<u32, DecodeError>

Decode a u32 value. Read more
Source§

fn decode_u64(&mut self) -> Result<u64, DecodeError>

Decode a u64 value. Read more
Source§

fn decode_u128(&mut self) -> Result<u128, DecodeError>

Decode a u128 value. Read more
Source§

fn decode_usize(&mut self) -> Result<usize, DecodeError>

Decode a usize value. Read more
Source§

fn decode_i8(&mut self) -> Result<i8, DecodeError>

Decode an i8 value. Read more
Source§

fn decode_i16(&mut self) -> Result<i16, DecodeError>

Decode an i16 value. Read more
Source§

fn decode_i32(&mut self) -> Result<i32, DecodeError>

Decode an i32 value. Read more
Source§

fn decode_i64(&mut self) -> Result<i64, DecodeError>

Decode an i64 value. Read more
Source§

fn decode_i128(&mut self) -> Result<i128, DecodeError>

Decode an i128 value. Read more
Source§

fn decode_isize(&mut self) -> Result<isize, DecodeError>

Decode an isize value. Read more
Source§

fn decode_f32(&mut self) -> Result<f32, DecodeError>

Decode an f32 value. Read more
Source§

fn decode_f64(&mut self) -> Result<f64, DecodeError>

Decode an f64 value. Read more
Source§

fn decode_bool(&mut self) -> Result<bool, DecodeError>

Decode a bool value. Read more
Source§

fn decode_slice_len(&mut self) -> Result<usize, DecodeError>

Decode the length of a slice. Read more
Source§

fn decode_array_len(&mut self) -> Result<usize, DecodeError>

Decode the length of an array. Read more
Source§

fn decode_map_len(&mut self) -> Result<usize, DecodeError>

Decode the length of a map. Read more
Source§

fn decode_variant_index(&mut self) -> Result<u32, DecodeError>

Decode an enum variant index. Read more
Source§

fn decode_byte_slice_len(&mut self) -> Result<usize, DecodeError>

Decode the length of a byte slice (Major Type 2 in CBOR). Read more
Source§

fn decode_byte_slice_or_array_len(&mut self) -> Result<(u8, usize), DecodeError>

Decode the length of a byte slice or an array (Major Type 2 or 4 in CBOR). Read more
Source§

fn decode_str_len(&mut self) -> Result<usize, DecodeError>

Decode the length of a string (Major Type 3 in CBOR). Read more
Source§

fn decode_struct_header(&mut self, _len: usize) -> Result<(), DecodeError>

Decode the header for a struct. Read more

Auto Trait Implementations§

§

impl<R, C, Context> Freeze for DecoderImpl<R, C, Context>
where R: Freeze, C: Freeze, Context: Freeze,

§

impl<R, C, Context> RefUnwindSafe for DecoderImpl<R, C, Context>
where R: RefUnwindSafe, C: RefUnwindSafe, Context: RefUnwindSafe,

§

impl<R, C, Context> Send for DecoderImpl<R, C, Context>
where R: Send, C: Send, Context: Send,

§

impl<R, C, Context> Sync for DecoderImpl<R, C, Context>
where R: Sync, C: Sync, Context: Sync,

§

impl<R, C, Context> Unpin for DecoderImpl<R, C, Context>
where R: Unpin, C: Unpin, Context: Unpin,

§

impl<R, C, Context> UnsafeUnpin for DecoderImpl<R, C, Context>
where R: UnsafeUnpin, C: UnsafeUnpin, Context: UnsafeUnpin,

§

impl<R, C, Context> UnwindSafe for DecoderImpl<R, C, Context>
where R: UnwindSafe, C: UnwindSafe, Context: UnwindSafe,

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 = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.