Skip to main content

BlockRead

Trait BlockRead 

Source
pub trait BlockRead: Send + Sync {
    // Required methods
    fn read_at(&self, offset: u64, buf: &mut [u8]) -> Result<(), Error>;
    fn size_bytes(&self) -> u64;
}
Expand description

Read-only random-access block device.

Required Methods§

Source

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

Read exactly buf.len() bytes starting at offset (bytes from the start of the device).

Source

fn size_bytes(&self) -> u64

Total device size in bytes. Used for bounds checks.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementations on Foreign Types§

Source§

impl<T> BlockRead for &T
where T: BlockRead + ?Sized,

Source§

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

Source§

fn size_bytes(&self) -> u64

Source§

impl<T> BlockRead for Box<T>
where T: BlockRead + ?Sized,

Source§

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

Source§

fn size_bytes(&self) -> u64

Source§

impl<T> BlockRead for Arc<T>
where T: BlockRead + ?Sized,

Source§

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

Source§

fn size_bytes(&self) -> u64

Implementors§