BlockDevice

Trait BlockDevice 

Source
pub trait BlockDevice {
    // Required methods
    fn read_blocks(&mut self, lba: u64, buf: &mut [u8]) -> Result<(), FsError>;
    fn write_blocks(&mut self, lba: u64, buf: &[u8]) -> Result<(), FsError>;
    fn block_size(&self) -> usize;
    fn num_blocks(&self) -> u64;
    fn flush(&mut self) -> Result<(), FsError>;
}
Expand description

Block device abstraction used by the filesystem layer.

Implementors provide sector-based access to a storage medium.

Required Methods§

Source

fn read_blocks(&mut self, lba: u64, buf: &mut [u8]) -> Result<(), FsError>

Read blocks starting at lba into buf.

Source

fn write_blocks(&mut self, lba: u64, buf: &[u8]) -> Result<(), FsError>

Write blocks starting at lba from buf.

Implementations may leave this unimplemented if the device is read-only.

Source

fn block_size(&self) -> usize

Return the logical block size in bytes.

Source

fn num_blocks(&self) -> u64

Return the total number of addressable blocks.

Source

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

Flush any buffered data to the underlying device.

Implementors§