pub struct VerifiedReader<R, H> { /* private fields */ }Expand description
Streaming reader that hashes data as it passes through.
Wraps any Read source for zero-copy verification.
Implementations§
Source§impl<R, H> VerifiedReader<R, H>
impl<R, H> VerifiedReader<R, H>
Source§impl<R: Read, H: Hasher> VerifiedReader<R, H>
impl<R: Read, H: Hasher> VerifiedReader<R, H>
Sourcepub fn read(&mut self, buf: &mut [u8]) -> Result<usize>
pub fn read(&mut self, buf: &mut [u8]) -> Result<usize>
Read data, hashing it in-place. Delegates to inner reader.
pub fn bytes_processed(&self) -> u64
Sourcepub fn finish(self, expected: &[u8]) -> Result<()>
pub fn finish(self, expected: &[u8]) -> Result<()>
Finalize verification against expected hash. Returns error on mismatch.
Sourcepub fn finish_with_constraints(
self,
expected: &[u8],
expected_bytes: Option<u64>,
) -> Result<VerificationReceipt>
pub fn finish_with_constraints( self, expected: &[u8], expected_bytes: Option<u64>, ) -> Result<VerificationReceipt>
Finalize verification with optional stream length enforcement.
§Errors
Returns VerifyError::HashMismatch when digest verification fails.
Returns VerifyError::SizeMismatch when expected_bytes is provided
and differs from the consumed stream length.
Auto Trait Implementations§
impl<R, H> Freeze for VerifiedReader<R, H>
impl<R, H> RefUnwindSafe for VerifiedReader<R, H>where
R: RefUnwindSafe,
H: RefUnwindSafe,
impl<R, H> Send for VerifiedReader<R, H>
impl<R, H> Sync for VerifiedReader<R, H>
impl<R, H> Unpin for VerifiedReader<R, H>
impl<R, H> UnsafeUnpin for VerifiedReader<R, H>where
R: UnsafeUnpin,
H: UnsafeUnpin,
impl<R, H> UnwindSafe for VerifiedReader<R, H>where
R: UnwindSafe,
H: UnwindSafe,
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