pub struct ReadBuffer<BS: BlockSizes> { /* private fields */ }
Expand description

Buffer for reading block-generated data.

Implementations§

source§

impl<BS: BlockSizes> ReadBuffer<BS>

source

pub fn get_pos(&self) -> usize

Return current cursor position.

source

pub fn size(&self) -> usize

Return size of the internal buffer in bytes.

source

pub fn remaining(&self) -> usize

Return number of remaining bytes in the internal buffer.

source

pub fn read(&mut self, data: &mut [u8], gen_block: impl FnMut(&mut Block<Self>))

Write remaining data inside buffer into data, fill remaining space in data with blocks generated by gen_block, and save leftover data from the last generated block into buffer for future use.

source

pub fn serialize(&self) -> Block<Self>

Serialize buffer into a byte array.

source

pub fn deserialize(buffer: &Block<Self>) -> Result<Self, Error>

Deserialize buffer from a byte array.

Trait Implementations§

source§

impl<BS: BlockSizes> BlockSizeUser for ReadBuffer<BS>

§

type BlockSize = BS

Size of the block in bytes.
source§

fn block_size() -> usize

Return block size in bytes.
source§

impl<BS: BlockSizes> Clone for ReadBuffer<BS>

source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<BS: BlockSizes> Debug for ReadBuffer<BS>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<BS: BlockSizes> Default for ReadBuffer<BS>

source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<BS> RefUnwindSafe for ReadBuffer<BS>
where <BS as ArraySize>::ArrayType<u8>: RefUnwindSafe,

§

impl<BS> Send for ReadBuffer<BS>
where <BS as ArraySize>::ArrayType<u8>: Send,

§

impl<BS> Sync for ReadBuffer<BS>
where <BS as ArraySize>::ArrayType<u8>: Sync,

§

impl<BS> Unpin for ReadBuffer<BS>
where <BS as ArraySize>::ArrayType<u8>: Unpin,

§

impl<BS> UnwindSafe for ReadBuffer<BS>
where <BS as ArraySize>::ArrayType<u8>: UnwindSafe,

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> Same for T

§

type Output = T

Should always be Self
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.