embassy-usb

Crates

git

Versions

default

Flavors

Skip to main content

SectorCache

Struct SectorCache 

Source
pub struct SectorCache<'a, D> { /* private fields */ }
Expand description

A cacheing wrapper for AsyncBlockDevice that aggregates writes to a device with large blocks, eliminating multiple flash read-erase-write cycles.

Reads and caches one device block in buf, written back when required or on flush.

Implementations§

Source§

impl<'a, D: AsyncBlockDevice> SectorCache<'a, D>

Source

pub fn new(device: D, buf: &'a mut [u8], block_size: u32) -> Self

Cache one block of device in buf

Trait Implementations§

Source§

impl<'a, D: AsyncBlockDevice> AsyncBlockDevice for SectorCache<'a, D>

Source§

type Error = <D as AsyncBlockDevice>::Error

Error type returned by storage operations.
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§

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

Reads consecutive logical blocks starting at lba into buf. Read more
Source§

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

Writes consecutive logical blocks starting at lba from data. Read more
Source§

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

Flushes pending writes to backing storage.
Source§

fn is_write_protected(&self) -> bool

Returns whether the media is write-protected.

Auto Trait Implementations§

§

impl<'a, D> !UnwindSafe for SectorCache<'a, D>

§

impl<'a, D> Freeze for SectorCache<'a, D>
where D: Freeze,

§

impl<'a, D> RefUnwindSafe for SectorCache<'a, D>
where D: RefUnwindSafe,

§

impl<'a, D> Send for SectorCache<'a, D>
where D: Send,

§

impl<'a, D> Sync for SectorCache<'a, D>
where D: Sync,

§

impl<'a, D> Unpin for SectorCache<'a, D>
where D: Unpin,

§

impl<'a, D> UnsafeUnpin for SectorCache<'a, D>
where D: UnsafeUnpin,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.