pub struct ReadBuffer<BS: ArraySize> { /* private fields */ }Expand description
Buffer for reading block-generated data.
Implementations§
Source§impl<BS: ArraySize> ReadBuffer<BS>
impl<BS: ArraySize> ReadBuffer<BS>
Sourcepub fn get_pos(&self) -> usize
pub fn get_pos(&self) -> usize
Return current cursor position, i.e. how many bytes were read from the buffer.
Sourcepub fn read_cached(&mut self, len: usize) -> &[u8]
pub fn read_cached(&mut self, len: usize) -> &[u8]
Read up to len bytes of remaining data in the buffer.
Returns slice with length of ret_len = min(len, buffer.remaining()) bytes
and sets the cursor position to buffer.get_pos() + ret_len.
Sourcepub fn write_block(
&mut self,
read_len: usize,
gen_block: impl FnOnce(&mut Array<u8, BS>),
read_fn: impl FnOnce(&[u8]),
)
pub fn write_block( &mut self, read_len: usize, gen_block: impl FnOnce(&mut Array<u8, BS>), read_fn: impl FnOnce(&[u8]), )
Write new block and consume read_len bytes from it.
If read_len is equal to zero, immediately returns without calling the closures.
Otherwise, the method calls gen_block to fill the internal buffer,
passes to read_fn slice with first read_len bytes of the block,
and sets the cursor position to read_len.
§Panics
If read_len is bigger than block size.
Trait Implementations§
Source§impl<BS: ArraySize> Clone for ReadBuffer<BS>
impl<BS: ArraySize> Clone for ReadBuffer<BS>
Source§impl<BS: ArraySize> Debug for ReadBuffer<BS>
impl<BS: ArraySize> Debug for ReadBuffer<BS>
Auto Trait Implementations§
impl<BS> Freeze for ReadBuffer<BS>
impl<BS> RefUnwindSafe for ReadBuffer<BS>
impl<BS> Send for ReadBuffer<BS>
impl<BS> Sync for ReadBuffer<BS>
impl<BS> Unpin for ReadBuffer<BS>
impl<BS> UnwindSafe for ReadBuffer<BS>
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