Struct bincode::de::DecoderImpl

source ·
pub struct DecoderImpl<R, C: Config> { /* 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::de::{DecoderImpl, Decode};
let mut decoder = DecoderImpl::new(some_reader, bincode::config::standard());
// this u32 can be any Decode
let value = u32::decode(&mut decoder).unwrap();

Implementations§

source§

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

source

pub fn new(reader: R, config: C) -> DecoderImpl<R, C>

Construct a new Decoder

Trait Implementations§

source§

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

§

type BR = R

The concrete BorrowReader type
source§

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

Rerturns a mutable reference to the borrow reader
source§

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

§

type R = R

The concrete Reader type
§

type C = C

The concrete Config 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>().
source§

fn unclaim_bytes_read(&mut self, n: usize)

Notify the decoder that n bytes are being reclaimed. Read more
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

Auto Trait Implementations§

§

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

§

impl<R, C> RefUnwindSafe for DecoderImpl<R, C>

§

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

§

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

§

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

§

impl<R, C> UnwindSafe for DecoderImpl<R, C>
where R: UnwindSafe, C: 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>,

§

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>,

§

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.