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>
impl<R: Reader, C: Config> DecoderImpl<R, C>
sourcepub fn new(reader: R, config: C) -> DecoderImpl<R, C>
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>
impl<'de, R: BorrowReader<'de>, C: Config> BorrowDecoder<'de> for DecoderImpl<R, C>
§type BR = R
type BR = R
The concrete BorrowReader type
source§fn borrow_reader(&mut self) -> &mut Self::BR
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>
impl<R: Reader, C: Config> Decoder for DecoderImpl<R, C>
source§fn claim_bytes_read(&mut self, n: usize) -> Result<(), DecodeError>
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)
fn unclaim_bytes_read(&mut self, n: usize)
Notify the decoder that
n
bytes are being reclaimed. Read moresource§fn claim_container_read<T>(&mut self, len: usize) -> Result<(), DecodeError>
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>
impl<R, C> RefUnwindSafe for DecoderImpl<R, C>where
R: RefUnwindSafe,
C: RefUnwindSafe,
impl<R, C> Send for DecoderImpl<R, C>
impl<R, C> Sync for DecoderImpl<R, C>
impl<R, C> Unpin for DecoderImpl<R, C>
impl<R, C> UnwindSafe for DecoderImpl<R, C>where
R: UnwindSafe,
C: UnwindSafe,
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more