Trait axdriver::prelude::BlockDriverOps

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]
    ) -> Result<(), DevError>;
    fn write_block(&mut self, block_id: u64, buf: &[u8]) -> Result<(), DevError>;
    fn flush(&mut self) -> Result<(), DevError>;
}
Available on crate feature block only.
Expand description

Operations that require a block storage device driver to implement.

Required Methods§

fn num_blocks(&self) -> u64

The number of blocks in this storage device.

The total size of the device is num_blocks() * block_size().

fn block_size(&self) -> usize

The size of each block in bytes.

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

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.

fn write_block(&mut self, block_id: u64, buf: &[u8]) -> Result<(), DevError>

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.

fn flush(&mut self) -> Result<(), DevError>

Flushes the device to write all pending data to the storage.

Implementations on Foreign Types§

§

impl<H, T> BlockDriverOps for VirtIoBlkDev<H, T>
where H: Hal, T: Transport,

§

fn num_blocks(&self) -> u64

§

fn block_size(&self) -> usize

§

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

§

fn write_block(&mut self, block_id: u64, buf: &[u8]) -> Result<(), DevError>

§

fn flush(&mut self) -> Result<(), DevError>

Implementors§

§

impl BlockDriverOps for RamDisk

§

impl BlockDriverOps for SDHCIDriver