pub struct IndexedReader<R: ReadAt> { /* private fields */ }Expand description
A Read and Seek view of decompressed bytes described by an index.
Seeking resumes at the nearest preceding checkpoint and discards output up to the requested byte. Gzip-member and zlib-header checkpoints permit full checksum verification, including discarded bytes. An interior DEFLATE checkpoint cannot authenticate the skipped prefix because the index does not store its checksum state. Raw DEFLATE has no container checksum.
The index is validated and a known compressed size is compared with the source before construction succeeds. Callers remain responsible for pairing indexes without a recorded size with the source from which they were built.
Implementations§
Source§impl<R: ReadAt> IndexedReader<R>
impl<R: ReadAt> IndexedReader<R>
Sourcepub fn new(source: R, index: DeflateIndex) -> Result<Self, IndexedReaderError>
pub fn new(source: R, index: DeflateIndex) -> Result<Self, IndexedReaderError>
Opens source for random access through index.
§Errors
Returns an error when the index violates its invariants, the source length cannot be read or disagrees with a known index size, or the raw inflate backend cannot be initialized.
Sourcepub fn with_window_cache_bytes(self, bytes: usize) -> Self
pub fn with_window_cache_bytes(self, bytes: usize) -> Self
Sets the expanded-window cache budget in bytes.
Sourcepub const fn index(&self) -> &DeflateIndex
pub const fn index(&self) -> &DeflateIndex
Returns the index backing this reader.
Sourcepub const fn position(&self) -> u64
pub const fn position(&self) -> u64
Returns the decompressed offset of the next byte a read returns.
Sourcepub fn into_inner(self) -> (R, DeflateIndex)
pub fn into_inner(self) -> (R, DeflateIndex)
Returns the source and index, discarding decoding state.
Sourcepub fn seek_to_line(&mut self, line: u64) -> Result<u64>
pub fn seek_to_line(&mut self, line: u64) -> Result<u64>
Seeks to the first byte of zero-based line and returns its byte offset.
The reader resumes from the nearest preceding annotated checkpoint and scans forward only far enough to find the requested newline. Seeking beyond the recorded lines positions the reader at decoded EOF.
§Errors
Returns io::ErrorKind::Unsupported unless the index carries a total
line count and a line offset for every checkpoint. Other errors have the
same meaning as Read and Seek errors from this reader.
Trait Implementations§
Source§impl<R: ReadAt> Read for IndexedReader<R>
impl<R: ReadAt> Read for IndexedReader<R>
Source§fn read(&mut self, output: &mut [u8]) -> Result<usize>
fn read(&mut self, output: &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)