pub trait BlockDevice: Send {
// Required methods
fn block_size(&self) -> u32;
fn block_count(&self) -> u64;
fn read_blocks(
&mut self,
buf: &mut [u8],
block_id: u64,
block_count: u32,
) -> Result<()>;
fn write_blocks(
&mut self,
buf: &[u8],
block_id: u64,
block_count: u32,
) -> Result<()>;
// Provided methods
fn open(&mut self) -> Result<()> { ... }
fn close(&mut self) -> Result<()> { ... }
}Expand description
Trait for block device operations.
Implement this trait to provide a custom block device backend. The block device must support reading and writing at block granularity.
Required Methods§
Sourcefn block_size(&self) -> u32
fn block_size(&self) -> u32
Returns the physical block size in bytes.
Sourcefn block_count(&self) -> u64
fn block_count(&self) -> u64
Returns the total number of blocks.