pub struct VerifyingReader<R> { /* private fields */ }Expand description
A reader that verifies decompressed data against the checksum and size recorded in the archive.
The check runs once the underlying stream reaches EOF, so reading the entry
to completion validates it automatically. A caller that would otherwise stop
early can force the check by calling VerifyingReader::finish. Note that a
partially-read reader that is simply dropped performs no verification.
Implementations§
Source§impl<R> VerifyingReader<R>
impl<R> VerifyingReader<R>
Sourcepub fn new(reader: R, expected: SaveVerification) -> Self
pub fn new(reader: R, expected: SaveVerification) -> Self
Wraps a decompressed reader with the expected verification values.
Sourcepub fn verification(&self) -> SaveVerification
pub fn verification(&self) -> SaveVerification
Returns the expected checksum and size this reader validates against.
Sourcepub fn into_inner(self) -> R
pub fn into_inner(self) -> R
Consumes this reader, returning the inner reader without verifying.
Source§impl<R: Read> VerifyingReader<R>
impl<R: Read> VerifyingReader<R>
Sourcepub fn finish(self) -> Result<R, EnvelopeError>
pub fn finish(self) -> Result<R, EnvelopeError>
Reads any remaining data, then verifies the checksum and size.
Returns the inner reader on success so the decompressor can be recovered.
A checksum or size mismatch is returned as an EnvelopeError.
Trait Implementations§
Source§impl<R: Debug> Debug for VerifyingReader<R>
impl<R: Debug> Debug for VerifyingReader<R>
Source§impl<R: Read> Read for VerifyingReader<R>
impl<R: Read> Read for VerifyingReader<R>
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>) -> Result<usize, Error>
fn read_to_end(&mut self, buf: &mut Vec<u8>) -> 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<'_, u8>) -> Result<(), Error>
fn read_buf(&mut self, buf: BorrowedCursor<'_, u8>) -> Result<(), Error>
read_buf)Source§fn read_buf_exact(
&mut self,
cursor: BorrowedCursor<'_, u8>,
) -> Result<(), Error>
fn read_buf_exact( &mut self, cursor: BorrowedCursor<'_, u8>, ) -> 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 more1.0.0 · Source§fn chain<R>(self, next: R) -> Chain<Self, R> ⓘ
fn chain<R>(self, next: R) -> Chain<Self, R> ⓘ
1.0.0 · Source§fn take(self, limit: u64) -> Take<Self> ⓘwhere
Self: Sized,
fn take(self, limit: u64) -> Take<Self> ⓘwhere
Self: Sized,
limit bytes from it. Read moreSource§fn read_array<const N: usize>(&mut self) -> Result<[u8; N], Error>where
Self: Sized,
fn read_array<const N: usize>(&mut self) -> Result<[u8; N], Error>where
Self: Sized,
read_array)