Trait Interface

Source
pub trait Interface: DriverGeneric {
    // Required methods
    fn num_blocks(&self) -> usize;
    fn block_size(&self) -> usize;
    fn read_block(
        &mut self,
        block_id: usize,
        buf: &mut [u8],
    ) -> Result<(), Error>;
    fn write_block(&mut self, block_id: usize, buf: &[u8]) -> Result<(), Error>;
    fn flush(&mut self) -> Result<(), Error>;
}
Expand description

Operations that require a block storage device driver to implement.

Required Methods§

Source

fn num_blocks(&self) -> usize

The number of blocks in this storage device.

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

Source

fn block_size(&self) -> usize

The size of each block in bytes.

Source

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

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.

Source

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

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.

Source

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

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

Implementors§