ReaderAt

Trait ReaderAt 

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

    // Provided method
    fn read_exact_at(&self, buf: &mut [u8], offset: u64) -> Result<()> { ... }
}
Expand description

A trait for objects that can be read from at a specific offset.

Required Methods§

Source

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

Reads up to buf.len() bytes into buf starting at offset. Returns the number of bytes read. This method does not affect the current cursor position of the reader if it has one.

Provided Methods§

Source

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

Reads exactly buf.len() bytes into buf starting at offset. If EOF is reached before buf is filled, an error of kind ErrorKind::UnexpectedEof is returned.

Implementations on Foreign Types§

Source§

impl ReaderAt for &[u8]

Implement ReaderAt for byte slices, useful for testing or in-memory data.

Source§

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

Source§

impl ReaderAt for File

Available on Unix only.

Implement ReaderAt for std::fs::File on Unix-like systems.

Source§

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

Source§

impl ReaderAt for Cursor<Vec<u8>>

Implement ReaderAt for std::io::Cursor<Vec<u8>>.

Source§

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

Implementors§