pub trait ReaderAt {
// Required method
fn read_at(&self, buf: &mut [u8], offset: u64) -> Result<usize>;
// Provided method
fn read_exact_at(&self, buf: &mut [u8], offset: u64) -> Result<()> { ... }
}Expand description
Provides reading bytes at a specific offset
This trait is similar to std::io::Read but with an additional offset
parameter that signals where the read should begin offset from the start of
the data. This allows methods to not require a mutable reference to the
reader, which is critical for zip files to easily offer decompression of
multiple files simultaneously without needing to store them in memory.
This trait is modelled after Go’s
io.ReaderAt interface, which is used by
their own Zip implementation.
Required Methods§
Provided Methods§
Sourcefn read_exact_at(&self, buf: &mut [u8], offset: u64) -> Result<()>
fn read_exact_at(&self, buf: &mut [u8], offset: u64) -> Result<()>
Sibling to read_exact, but at an offset