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
sourceimpl 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
sourceimpl Clone for OutputReader
impl Clone for OutputReader
sourcefn clone(&self) -> OutputReaderⓘNotable traits for OutputReaderimpl Read for OutputReader
fn clone(&self) -> OutputReaderⓘNotable traits for OutputReaderimpl Read for OutputReader
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for OutputReader
impl Debug for OutputReader
sourceimpl Read for OutputReader
impl Read for OutputReader
sourcefn read(&mut self, buf: &mut [u8]) -> Result<usize>
fn read(&mut self, buf: &mut [u8]) -> Result<usize>
Pull some bytes from this source into the specified buffer, returning how many bytes were read. Read more
1.36.0 · sourcefn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize, Error>
fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize, Error>
Like read
, except that it reads into a slice of buffers. Read more
sourcefn is_read_vectored(&self) -> bool
fn is_read_vectored(&self) -> bool
can_vector
)Determines if this Read
er has an efficient read_vectored
implementation. Read more
1.0.0 · sourcefn 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>
Read all bytes until EOF in this source, placing them into buf
. Read more
1.0.0 · sourcefn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
Read all bytes until EOF in this source, appending them to buf
. Read more
1.6.0 · sourcefn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
Read the exact number of bytes required to fill buf
. Read more
sourcefn read_buf(&mut self, buf: &mut ReadBuf<'_>) -> Result<(), Error>
fn read_buf(&mut self, buf: &mut ReadBuf<'_>) -> Result<(), Error>
read_buf
)Pull some bytes from this source into the specified buffer. Read more
sourcefn read_buf_exact(&mut self, buf: &mut ReadBuf<'_>) -> Result<(), Error>
fn read_buf_exact(&mut self, buf: &mut ReadBuf<'_>) -> Result<(), Error>
read_buf
)Read the exact number of bytes required to fill buf
. Read more
1.0.0 · sourcefn by_ref(&mut self) -> &mut Self
fn by_ref(&mut self) -> &mut Self
Creates a “by reference” adaptor for this instance of Read
. Read more
sourceimpl Seek for OutputReader
impl Seek for OutputReader
sourcefn seek(&mut self, pos: SeekFrom) -> Result<u64>
fn seek(&mut self, pos: SeekFrom) -> Result<u64>
Seek to an offset, in bytes, in a stream. Read more
1.55.0 · sourcefn rewind(&mut self) -> Result<(), Error>
fn rewind(&mut self) -> Result<(), Error>
Rewind to the beginning of a stream. Read more
Auto Trait Implementations
impl RefUnwindSafe for OutputReader
impl Send for OutputReader
impl Sync for OutputReader
impl Unpin for OutputReader
impl UnwindSafe for OutputReader
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more