Skip to main content

BlockDevice

Trait BlockDevice 

Source
pub trait BlockDevice {
    // Required methods
    fn read_block(&mut self, lba: u64, buf: &mut [u8]) -> Result<(), ()>;
    fn block_size(&self) -> u64;
}
Expand description

Trait for block-based storage devices.

Required Methods§

Source

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

Read blocks from the device into the buffer.

§Arguments
  • lba - Logical Block Address to start reading from
  • buf - Buffer to read into (must be at least block_size() bytes)
§Returns

Ok(()) on success, Err(()) on failure.

Source

fn block_size(&self) -> u64

Get the block size in bytes (typically 512 or 4096).

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§