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

    fn read_exact_at(&self, buf: &mut [u8], offset: u64) -> Result<()> { ... }
}
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

Reads a number of bytes starting from a given offset.

Returns the number of bytes read.

The offset is relative to the start of the file and thus independent from the current cursor.

The current file cursor is not affected by this function.

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

Provided methods

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

The offset is relative to the start of the file and thus independent from the current cursor.

The current file cursor is not affected by this function.

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.

Implementations on Foreign Types

Implementors