Skip to main content

ReadAt

Trait ReadAt 

pub trait ReadAt {
    type Error: Error + 'static;

    // Required methods
    fn read_exact_at(
        &self,
        offset: u64,
        buf: &mut [u8],
    ) -> Result<(), Self::Error>;
    fn size(&self) -> Result<u64, Self::Error>;
}
Expand description

Source that reads bytes at an offset.

Required Associated Types§

type Error: Error + 'static

Error of a failed read.

Required Methods§

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

Fills buf with the bytes at offset.

§Errors

Returns an error if the read fails or the source ends before buf is full.

fn size(&self) -> Result<u64, Self::Error>

Returns the size of the source in bytes.

§Errors

Returns an error if the size can’t be determined.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

§

impl ReadAt for File

Available on crate feature std and (Unix or Windows) only.
§

type Error = Error

§

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

§

fn size(&self) -> Result<u64>

§

impl ReadAt for [u8]

§

type Error = SliceError

§

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

§

fn size(&self) -> Result<u64, SliceError>

§

impl<T: ReadAt + ?Sized> ReadAt for &T

§

type Error = <T as ReadAt>::Error

§

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

§

fn size(&self) -> Result<u64, Self::Error>

Implementors§