SliceReader

Struct 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 const fn new(bytes: &'storage [u8]) -> Self

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. Fill the given bytes argument with values. Exactly the length of the given slice must be filled, or else an error must be returned. Read more
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>,

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.