Trait ReadAt

Source
pub trait ReadAt: Array {
    // Required methods
    fn read_at(&self, buf: &mut [u8], offset: u64) -> Result<usize>;
    fn read_exact_at(&self, buf: &mut [u8], offset: u64) -> Result<()>;
    fn read_vectored_at(
        &self,
        bufs: &mut [IoSliceMut<'_>],
        offset: u64,
    ) -> Result<usize>;
    fn read_exact_vectored_at(
        &self,
        bufs: &mut [IoSliceMut<'_>],
        offset: u64,
    ) -> Result<()>;
    fn is_read_vectored_at(&self) -> bool;
    fn read_via_stream_at(&self, offset: u64) -> Result<StreamReader>;
}
Expand description

A trait for reading from arrays.

This is similar to std::io::Read except all of the reading functions take an offset parameter, specifying a position in the array to read at.

Unlike std::io::Read, ReadAt’s functions take a &self rather than a &mut self, since they don’t have a current position to mutate.

Required Methods§

Source

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

Reads a number of bytes starting from a given offset.

This is similar to std::os::unix::fs::FileExt::read_at, except it takes self by immutable reference since the entire side effect is I/O, and it’s supported on non-Unix platforms including Windows.

Source

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

Reads the exact number of byte required to fill buf from the given offset.

This is similar to std::os::unix::fs::FileExt::read_exact_at, except it takes self by immutable reference since the entire side effect is I/O, and it’s supported on non-Unix platforms including Windows.

Source

fn read_vectored_at( &self, bufs: &mut [IoSliceMut<'_>], offset: u64, ) -> Result<usize>

Is to read_vectored what read_at is to read.

Source

fn read_exact_vectored_at( &self, bufs: &mut [IoSliceMut<'_>], offset: u64, ) -> Result<()>

Is to read_exact_vectored what read_exact_at is to read_exact.

Source

fn is_read_vectored_at(&self) -> bool

Determines if Self has an efficient read_vectored_at implementation.

Source

fn read_via_stream_at(&self, offset: u64) -> Result<StreamReader>

Create a StreamReader which reads from the array at the given offset.

Implementations on Foreign Types§

Source§

impl ReadAt for Vec<u8>

Source§

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

Source§

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

Source§

fn read_vectored_at( &self, bufs: &mut [IoSliceMut<'_>], offset: u64, ) -> Result<usize>

Source§

fn read_exact_vectored_at( &self, bufs: &mut [IoSliceMut<'_>], offset: u64, ) -> Result<()>

Source§

fn is_read_vectored_at(&self) -> bool

Source§

fn read_via_stream_at(&self, _offset: u64) -> Result<StreamReader>

Source§

impl ReadAt for File

Source§

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

Source§

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

Source§

fn read_vectored_at( &self, bufs: &mut [IoSliceMut<'_>], offset: u64, ) -> Result<usize>

Source§

fn read_exact_vectored_at( &self, bufs: &mut [IoSliceMut<'_>], offset: u64, ) -> Result<()>

Source§

fn is_read_vectored_at(&self) -> bool

Source§

fn read_via_stream_at(&self, offset: u64) -> Result<StreamReader>

Source§

impl ReadAt for [u8]

Source§

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

Source§

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

Source§

fn read_vectored_at( &self, bufs: &mut [IoSliceMut<'_>], offset: u64, ) -> Result<usize>

Source§

fn read_exact_vectored_at( &self, bufs: &mut [IoSliceMut<'_>], offset: u64, ) -> Result<()>

Source§

fn is_read_vectored_at(&self) -> bool

Source§

fn read_via_stream_at(&self, _offset: u64) -> Result<StreamReader>

Implementors§