pub trait BlockDevice: Send + Sync {
// Required methods
fn name(&self) -> &str;
fn block_size(&self) -> usize;
fn block_count(&self) -> u64;
fn read_blocks(
&self,
start_block: u64,
buffer: &mut [u8],
) -> Result<(), KernelError>;
fn write_blocks(
&mut self,
start_block: u64,
buffer: &[u8],
) -> Result<(), KernelError>;
// Provided method
fn flush(&mut self) -> Result<(), KernelError> { ... }
}Expand description
Block device trait
Required Methods§
Sourcefn block_size(&self) -> usize
fn block_size(&self) -> usize
Get block size in bytes
Sourcefn block_count(&self) -> u64
fn block_count(&self) -> u64
Get total number of blocks
Sourcefn read_blocks(
&self,
start_block: u64,
buffer: &mut [u8],
) -> Result<(), KernelError>
fn read_blocks( &self, start_block: u64, buffer: &mut [u8], ) -> Result<(), KernelError>
Read blocks from device
Sourcefn write_blocks(
&mut self,
start_block: u64,
buffer: &[u8],
) -> Result<(), KernelError>
fn write_blocks( &mut self, start_block: u64, buffer: &[u8], ) -> Result<(), KernelError>
Write blocks to device
Provided Methods§
Sourcefn flush(&mut self) -> Result<(), KernelError>
fn flush(&mut self) -> Result<(), KernelError>
Flush any cached writes
Implementors§
impl BlockDevice for AhciBlockDevice
Available on crate feature
alloc only.