Trait driver_block::BlockDriverOps
source · pub trait BlockDriverOps: BaseDriverOps {
// Required methods
fn num_blocks(&self) -> u64;
fn block_size(&self) -> usize;
fn read_block(&mut self, block_id: u64, buf: &mut [u8]) -> DevResult;
fn write_block(&mut self, block_id: u64, buf: &[u8]) -> DevResult;
fn flush(&mut self) -> DevResult;
}
Expand description
Operations that require a block storage device driver to implement.
Required Methods§
sourcefn num_blocks(&self) -> u64
fn num_blocks(&self) -> u64
The number of blocks in this storage device.
The total size of the device is num_blocks() * block_size()
.
sourcefn block_size(&self) -> usize
fn block_size(&self) -> usize
The size of each block in bytes.
sourcefn read_block(&mut self, block_id: u64, buf: &mut [u8]) -> DevResult
fn read_block(&mut self, block_id: u64, buf: &mut [u8]) -> DevResult
Reads blocked data from the given block.
The size of the buffer may exceed the block size, in which case multiple contiguous blocks will be read.
sourcefn write_block(&mut self, block_id: u64, buf: &[u8]) -> DevResult
fn write_block(&mut self, block_id: u64, buf: &[u8]) -> DevResult
Writes blocked data to the given block.
The size of the buffer may exceed the block size, in which case multiple contiguous blocks will be written.
Implementors§
impl BlockDriverOps for SDHCIDriver
Available on crate feature
bcm2835-sdhci
only.impl BlockDriverOps for RamDisk
Available on crate feature
ramdisk
only.