Skip to main content

BlockDevice

Trait BlockDevice 

Source
pub trait BlockDevice {
    type Error;

    // Required methods
    async fn read_block(
        &mut self,
        block: u32,
        buffer: &mut [u8; 512],
    ) -> Result<(), Self::Error>;
    async fn num_blocks(&mut self) -> Result<u32, Self::Error>;
}
Expand description

A device that reads 512-byte blocks. The filesystem layer never assumes anything about the device beyond this.

Required Associated Types§

Source

type Error

The error a read can fail with.

Required Methods§

Source

async fn read_block( &mut self, block: u32, buffer: &mut [u8; 512], ) -> Result<(), Self::Error>

Reads block number block (counted from 0) into buffer.

Source

async fn num_blocks(&mut self) -> Result<u32, Self::Error>

The number of blocks the device holds.

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementations on Foreign Types§

Source§

impl<D: BlockDevice + ?Sized> BlockDevice for &mut D

A device lent to the filesystem for a while: a mount that borrows the card and gives it back.

Source§

type Error = <D as BlockDevice>::Error

Source§

async fn read_block( &mut self, block: u32, buffer: &mut [u8; 512], ) -> Result<(), Self::Error>

Source§

async fn num_blocks(&mut self) -> Result<u32, Self::Error>

Implementors§

Source§

impl<SPI, D> BlockDevice for SpiSdCard<SPI, D>
where SPI: SpiDevice<u8>, D: DelayNs,