Struct bincode::de::read::SliceReader

source ·
pub struct SliceReader<'storage> { /* private fields */ }
Expand description

A reader type for &[u8] slices. Implements both Reader and BorrowReader, and thus can be used for borrowed data.

Implementations§

source§

impl<'storage> SliceReader<'storage>

source

pub fn new(bytes: &'storage [u8]) -> SliceReader<'storage>

Constructs a slice reader

Trait Implementations§

source§

impl<'storage> BorrowReader<'storage> for SliceReader<'storage>

source§

fn take_bytes(&mut self, length: usize) -> Result<&'storage [u8], DecodeError>

Read exactly length bytes and return a slice to this data. If not enough bytes could be read, an error should be returned. Read more
source§

impl<'storage> Reader for SliceReader<'storage>

source§

fn read(&mut self, bytes: &mut [u8]) -> Result<(), DecodeError>

Fill the given bytes argument with values. Exactly the length of the given slice must be filled, or else an error must be returned.
source§

fn peek_read(&mut self, n: usize) -> Option<&'storage [u8]>

If this reader wraps a buffer of any kind, this function lets callers access contents of the buffer without passing data through a buffer first.
source§

fn consume(&mut self, n: usize)

If an implementation of peek_read is provided, an implementation of this function must be provided so that subsequent reads or peek-reads do not return the same bytes

Auto Trait Implementations§

§

impl<'storage> Freeze for SliceReader<'storage>

§

impl<'storage> RefUnwindSafe for SliceReader<'storage>

§

impl<'storage> Send for SliceReader<'storage>

§

impl<'storage> Sync for SliceReader<'storage>

§

impl<'storage> Unpin for SliceReader<'storage>

§

impl<'storage> UnwindSafe for SliceReader<'storage>

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.