Skip to main content

VerifiedReader

Struct VerifiedReader 

Source
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>

Source

pub fn new(reader: R, hasher: H) -> Self

Create a new verified reader.

Source§

impl<R: Read, H: Hasher> VerifiedReader<R, H>

Source

pub fn read(&mut self, buf: &mut [u8]) -> Result<usize>

Read data, hashing it in-place. Delegates to inner reader.

Source

pub fn bytes_processed(&self) -> u64

Source

pub fn finish(self, expected: &[u8]) -> Result<()>

Finalize verification against expected hash. Returns error on mismatch.

Source

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>
where R: Freeze, H: Freeze,

§

impl<R, H> RefUnwindSafe for VerifiedReader<R, H>

§

impl<R, H> Send for VerifiedReader<R, H>
where R: Send, H: Send,

§

impl<R, H> Sync for VerifiedReader<R, H>
where R: Sync, H: Sync,

§

impl<R, H> Unpin for VerifiedReader<R, H>
where R: Unpin, H: Unpin,

§

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> 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

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

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>,

Source§

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.