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§
Trait Implementations§
Source§impl<'storage> BorrowReader<'storage> for SliceReader<'storage>
impl<'storage> BorrowReader<'storage> for SliceReader<'storage>
Source§fn take_bytes(&mut self, length: usize) -> Result<&'storage [u8], DecodeError>
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 moreSource§impl<'storage> Reader for SliceReader<'storage>
impl<'storage> Reader for SliceReader<'storage>
Source§fn read(&mut self, bytes: &mut [u8]) -> Result<(), DecodeError>
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.
The buffer is initialized, and implementations may inspect its contents before writing. Read moreSource§fn peek_read(&mut self, n: usize) -> Option<&'storage [u8]>
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)
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 bytesAuto Trait Implementations§
impl<'storage> Forget for SliceReader<'storage>
impl<'storage> Freeze for SliceReader<'storage>
impl<'storage> Move 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> UnsafeUnpin for SliceReader<'storage>
impl<'storage> UnwindSafe for SliceReader<'storage>
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