pub trait ReadAt: Array {
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
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.
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.
fn read_vectored_at(
&self,
bufs: &mut [IoSliceMut<'_>],
offset: u64
) -> Result<usize>
fn read_vectored_at(
&self,
bufs: &mut [IoSliceMut<'_>],
offset: u64
) -> Result<usize>
Is to read_vectored
what read_at
is to read
.
fn read_exact_vectored_at(
&self,
bufs: &mut [IoSliceMut<'_>],
offset: u64
) -> Result<()>
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
.
fn is_read_vectored_at(&self) -> bool
fn is_read_vectored_at(&self) -> bool
Determines if Self
has an efficient read_vectored_at
implementation.
fn read_via_stream_at(&self, offset: u64) -> Result<StreamReader>
fn read_via_stream_at(&self, offset: u64) -> Result<StreamReader>
Create a StreamReader
which reads from the array at the given offset.