Skip to main content

ReaderAt

Trait ReaderAt 

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

Source

fn read_at(&self, buf: &mut [u8], offset: u64) -> Result<usize>

Read bytes from the reader at a specific offset

Provided Methods§

Source

fn read_exact_at(&self, buf: &mut [u8], offset: u64) -> Result<()>

Sibling to read_exact, but at an offset

Implementations on Foreign Types§

Source§

impl ReaderAt for &[u8]

Source§

fn read_at(&self, buf: &mut [u8], offset: u64) -> Result<usize>

Source§

impl ReaderAt for Vec<u8>

Source§

fn read_at(&self, buf: &mut [u8], offset: u64) -> Result<usize>

Source§

impl<R> ReaderAt for Cursor<R>
where R: AsRef<[u8]>,

Source§

fn read_at(&self, buf: &mut [u8], offset: u64) -> Result<usize>

Source§

impl<T: ReaderAt + ?Sized> ReaderAt for Box<T>

Source§

fn read_at(&self, buf: &mut [u8], offset: u64) -> Result<usize>

Source§

impl<T: ReaderAt + ?Sized> ReaderAt for Rc<T>

Source§

fn read_at(&self, buf: &mut [u8], offset: u64) -> Result<usize>

Source§

impl<T: ReaderAt + ?Sized> ReaderAt for Arc<T>

Source§

fn read_at(&self, buf: &mut [u8], offset: u64) -> Result<usize>

Source§

impl<T: ReaderAt> ReaderAt for &T

Source§

fn read_at(&self, buf: &mut [u8], offset: u64) -> Result<usize>

Source§

impl<T: ReaderAt> ReaderAt for &mut T

Source§

fn read_at(&self, buf: &mut [u8], offset: u64) -> Result<usize>

Implementors§