block_buffer

Type Alias LazyBuffer

Source
pub type LazyBuffer<B> = BlockBuffer<B, Lazy>;
Expand description

Lazy block buffer.

Aliased Type§

struct LazyBuffer<B> { /* private fields */ }

Implementations

Source§

impl<BlockSize, Kind> BlockBuffer<BlockSize, Kind>
where BlockSize: ArrayLength<u8> + IsLess<U256>, Le<BlockSize, U256>: NonZero, Kind: BufferKind,

Source

pub fn new(buf: &[u8]) -> Self

Create new buffer from slice.

§Panics

If slice length is not valid for used buffer kind.

Source

pub fn try_new(buf: &[u8]) -> Result<Self, Error>

Create new buffer from slice.

Returns an error if slice length is not valid for used buffer kind.

Source

pub fn digest_blocks( &mut self, input: &[u8], compress: impl FnMut(&[Block<BlockSize>]), )

Digest data in input in blocks of size BlockSize using the compress function, which accepts slice of blocks.

Source

pub fn reset(&mut self)

Reset buffer by setting cursor position to zero.

Source

pub fn pad_with_zeros(&mut self) -> &mut Block<BlockSize>

Pad remaining data with zeros and return resulting block.

Source

pub fn get_pos(&self) -> usize

Return current cursor position.

Source

pub fn get_data(&self) -> &[u8]

Return slice of data stored inside the buffer.

Source

pub fn set(&mut self, buf: Block<BlockSize>, pos: usize)

Set buffer content and cursor position.

§Panics

If pos is bigger or equal to block size.

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.

Trait Implementations

Source§

impl<BlockSize, Kind> Clone for BlockBuffer<BlockSize, Kind>
where BlockSize: ArrayLength<u8> + IsLess<U256>, Le<BlockSize, U256>: NonZero, Kind: BufferKind,

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<BlockSize, Kind> Debug for BlockBuffer<BlockSize, Kind>
where BlockSize: ArrayLength<u8> + IsLess<U256> + Debug, Le<BlockSize, U256>: NonZero, Kind: BufferKind + Debug,

Source§

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

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

impl<BlockSize, Kind> Default for BlockBuffer<BlockSize, Kind>
where BlockSize: ArrayLength<u8> + IsLess<U256>, Le<BlockSize, U256>: NonZero, Kind: BufferKind,

Source§

fn default() -> Self

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