embassy-usb

Crates

git

Versions

default

Flavors

Skip to main content

BlockDevice

Trait BlockDevice 

Source
pub trait BlockDevice {
    type Error;

    // Required methods
    fn block_size(&self) -> u32;
    fn block_count(&self) -> u32;
    fn read_blocks(
        &mut self,
        lba: u32,
        buf: &mut [u8],
    ) -> Result<(), Self::Error>;
    fn write_blocks(&mut self, lba: u32, data: &[u8]) -> Result<(), Self::Error>;
    fn flush(&mut self) -> Result<(), Self::Error>;

    // Provided method
    fn is_write_protected(&self) -> bool { ... }
}
Expand description

Trait implemented by synchronous block devices used by MscClass.

Required Associated Types§

Source

type Error

Error type returned by storage operations.

Required Methods§

Source

fn block_size(&self) -> u32

Returns the block size in bytes.

Source

fn block_count(&self) -> u32

Returns the total amount of logical blocks.

Source

fn read_blocks(&mut self, lba: u32, buf: &mut [u8]) -> Result<(), Self::Error>

Reads consecutive logical blocks starting at lba into buf.

buf.len() is a non-zero multiple of self.block_size().

Source

fn write_blocks(&mut self, lba: u32, data: &[u8]) -> Result<(), Self::Error>

Writes consecutive logical blocks starting at lba from data.

data.len() is a non-zero multiple of self.block_size().

Source

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

Flushes pending writes to backing storage.

Provided Methods§

Source

fn is_write_protected(&self) -> bool

Returns whether the media is write-protected.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§