Skip to main content

ReadAt

Trait ReadAt 

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

Source

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

Reads a number of bytes starting from a given offset.

Returns the number of bytes read.

Note that similar to io::Read::read, it is not an error to return with a short read.

Provided Methods§

Source

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.

Source

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.

Implementations on Foreign Types§

Source§

impl ReadAt for Cow<'_, [u8]>

Source§

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

Source§

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

Source§

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

Source§

impl ReadAt for Vec<u8>

Source§

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

Source§

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

Source§

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

Source§

impl ReadAt for Empty

Source§

fn read_at(&self, _buf: &mut [u8], _offset: u64) -> Result<usize, Error>

Source§

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

Source§

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

Source§

impl ReadAt for [u8]

Source§

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

Source§

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

Source§

impl<'a, F> ReadAt for StreamReader<'a, F>
where F: ReadAt,

Source§

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

Source§

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

Source§

impl<'a, F> ReadAt for StreamReader<'a, F>
where F: ReadAt,

Source§

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

Source§

impl<R> ReadAt for &R
where R: ReadAt + ?Sized,

Source§

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

Source§

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

Source§

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

Source§

impl<R> ReadAt for Box<R>
where R: ReadAt + ?Sized,

Source§

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

Source§

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

Source§

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

Source§

impl<R> ReadAt for Rc<R>
where R: ReadAt + ?Sized,

Source§

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

Source§

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

Source§

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

Source§

impl<R> ReadAt for Arc<R>
where R: ReadAt + ?Sized,

Source§

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

Source§

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

Source§

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

Source§

impl<T> ReadAt for Cursor<T>
where T: AsRef<[u8]>,

Source§

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

Source§

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

Source§

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

Source§

impl<const N: usize> ReadAt for [u8; N]

Source§

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

Source§

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

Source§

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

Implementors§

Source§

impl ReadAt for SyncFile

Source§

impl ReadAt for RandomAccessFile

Source§

impl<'a, F: ReadAt> ReadAt for ms_pdb::container::StreamReader<'a, F>

Source§

impl<T> ReadAt for Adapter<T>
where T: ReadAt + ?Sized,