pub trait ReadAt {
// Required method
fn read_at(&self, buf: &mut [u8], offset: u64) -> Result<usize, Error>;
// Provided methods
fn read_exact_at(&self, buf: &mut [u8], offset: u64) -> Result<(), Error> { ... }
fn read_vectored_at(
&self,
bufs: &mut [IoSliceMut<'_>],
offset: u64,
) -> Result<usize, Error> { ... }
}Expand description
The ReadAt trait allows for reading bytes from a source at a given offset.
Additionally, the methods of this trait only require a shared reference, which makes it ideal for parallel use.
Required Methods§
Provided Methods§
Sourcefn read_exact_at(&self, buf: &mut [u8], offset: u64) -> Result<(), Error>
fn read_exact_at(&self, buf: &mut [u8], offset: u64) -> Result<(), Error>
Reads the exact number of byte required to fill buf from the given offset.
§Errors
If this function encounters an error of the kind
io::ErrorKind::Interrupted then the error is ignored and the
operation will continue.
If this function encounters an “end of file” before completely filling
the buffer, it returns an error of the kind
io::ErrorKind::UnexpectedEof. The contents of buf are unspecified
in this case.
If any other read error is encountered then this function immediately returns. The contents of buf are unspecified in this case.
Sourcefn read_vectored_at(
&self,
bufs: &mut [IoSliceMut<'_>],
offset: u64,
) -> Result<usize, Error>
fn read_vectored_at( &self, bufs: &mut [IoSliceMut<'_>], offset: u64, ) -> Result<usize, Error>
Like read_at, except that it reads into a slice of buffers.
Data is copied to fill each buffer in order, with the final buffer written to possibly being only partially filled. This method must behave equivalently to a single call to read with concatenated buffers.