Struct blake3::OutputReader
source · pub struct OutputReader { /* private fields */ }
Expand description
An incremental reader for extended output, returned by
Hasher::finalize_xof
.
Outputs shorter than the default length of 32 bytes (256 bits) provide less security. An N-bit BLAKE3 output is intended to provide N bits of first and second preimage resistance and N/2 bits of collision resistance, for any N up to 256. Longer outputs don’t provide any additional security.
Shorter BLAKE3 outputs are prefixes of longer ones. Explicitly requesting a short output is equivalent to truncating the default-length output. (Note that this is different between BLAKE2 and BLAKE3.)
Implementations§
source§impl OutputReader
impl OutputReader
sourcepub fn fill(&mut self, buf: &mut [u8])
pub fn fill(&mut self, buf: &mut [u8])
Fill a buffer with output bytes and advance the position of the
OutputReader
. This is equivalent to Read::read
, except that it
doesn’t return a Result
. Both methods always fill the entire buffer.
Note that OutputReader
doesn’t buffer output bytes internally, so
calling fill
repeatedly with a short-length or odd-length slice will
end up performing the same compression multiple times. If you’re
reading output in a loop, prefer a slice length that’s a multiple of
64.
The maximum output size of BLAKE3 is 264-1 bytes. If you try to extract more than that, for example by seeking near the end and reading further, the behavior is unspecified.
sourcepub fn position(&self) -> u64
pub fn position(&self) -> u64
Return the current read position in the output stream. This is
equivalent to Seek::stream_position
, except that it doesn’t return
a Result
. The position of a new OutputReader
starts at 0, and each
call to fill
or Read::read
moves the position forward by the
number of bytes read.
sourcepub fn set_position(&mut self, position: u64)
pub fn set_position(&mut self, position: u64)
Seek to a new read position in the output stream. This is equivalent to
calling Seek::seek
with SeekFrom::Start
, except that it doesn’t
return a Result
.
Trait Implementations§
source§impl Clone for OutputReader
impl Clone for OutputReader
source§impl Debug for OutputReader
impl Debug for OutputReader
source§impl Read for OutputReader
impl Read for OutputReader
source§fn read(&mut self, buf: &mut [u8]) -> Result<usize>
fn read(&mut self, buf: &mut [u8]) -> Result<usize>
1.36.0 · source§fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize, Error>
fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize, Error>
read
, except that it reads into a slice of buffers. Read moresource§fn is_read_vectored(&self) -> bool
fn is_read_vectored(&self) -> bool
can_vector
)1.0.0 · source§fn read_to_end(&mut self, buf: &mut Vec<u8, Global>) -> Result<usize, Error>
fn read_to_end(&mut self, buf: &mut Vec<u8, Global>) -> Result<usize, Error>
buf
. Read more1.0.0 · source§fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
buf
. Read more1.6.0 · source§fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
buf
. Read moresource§fn read_buf(&mut self, buf: BorrowedCursor<'_>) -> Result<(), Error>
fn read_buf(&mut self, buf: BorrowedCursor<'_>) -> Result<(), Error>
read_buf
)source§fn read_buf_exact(&mut self, cursor: BorrowedCursor<'_>) -> Result<(), Error>
fn read_buf_exact(&mut self, cursor: BorrowedCursor<'_>) -> Result<(), Error>
read_buf
)cursor
. Read more1.0.0 · source§fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
Read
. Read more