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>
impl<'storage> SliceReader<'storage>
Sourcepub const fn new(bytes: &'storage [u8]) -> SliceReader<'storage>
pub const fn new(bytes: &'storage [u8]) -> SliceReader<'storage>
Constructs a slice reader
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.