Skip to main content

Device

Trait Device 

Source
pub trait Device: Send {
    // Required methods
    fn size_bytes(&self) -> Result<u64>;
    fn read_at(&mut self, offset: u64, buf: &mut [u8]) -> Result<()>;
    fn write_at(&mut self, offset: u64, buf: &[u8]) -> Result<()>;
    fn sync(&mut self) -> Result<()>;
    fn describe(&self) -> String;
}

Required Methods§

Source

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

Total addressable bytes of the underlying device.

Source

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

Read exactly buf.len() bytes at offset. Errors if read short.

Source

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

Write exactly buf.len() bytes at offset. Errors if write short.

Source

fn sync(&mut self) -> Result<()>

Force any buffered writes to the physical medium.

Source

fn describe(&self) -> String

Human-readable identifier for log messages and the confirm prompt. e.g. “/dev/rdisk8 (64 GB SanDisk Cruzer)” or “in-memory test device”.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§