embassy-usb

Crates

git

Versions

default

Flavors

Skip to main content

BlockDeviceAdapter

Struct BlockDeviceAdapter 

Source
pub struct BlockDeviceAdapter<B, const SIZE: usize> { /* private fields */ }
Expand description

Adapts a block_device_driver::BlockDevice with SIZE-byte blocks into an AsyncBlockDevice.

Buffers, such as the block_buf given to MscClass::run, must be aligned to B::Align or the call panics.

Implementations§

Source§

impl<B: BlockDevice<SIZE>, const SIZE: usize> BlockDeviceAdapter<B, SIZE>

Source

pub async fn new(device: B) -> Result<Self, B::Error>

Wrap device, reading its size once.

Source

pub fn with_cache<'a>( self, buf: &'a mut Aligned<B::Align, [u8; SIZE]>, block_size: u32, ) -> SectorCache<'a, Self>

Present block_size-byte blocks through a SectorCache with an aligned device-block buffer.

Trait Implementations§

Source§

impl<B: BlockDevice<SIZE>, const SIZE: usize> AsyncBlockDevice for BlockDeviceAdapter<B, SIZE>

Available on crate feature block-device-driver only.
Source§

type Error = <B as BlockDevice<SIZE>>::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<B, const SIZE: usize> Freeze for BlockDeviceAdapter<B, SIZE>
where B: Freeze,

§

impl<B, const SIZE: usize> RefUnwindSafe for BlockDeviceAdapter<B, SIZE>
where B: RefUnwindSafe,

§

impl<B, const SIZE: usize> Send for BlockDeviceAdapter<B, SIZE>
where B: Send,

§

impl<B, const SIZE: usize> Sync for BlockDeviceAdapter<B, SIZE>
where B: Sync,

§

impl<B, const SIZE: usize> Unpin for BlockDeviceAdapter<B, SIZE>
where B: Unpin,

§

impl<B, const SIZE: usize> UnsafeUnpin for BlockDeviceAdapter<B, SIZE>
where B: UnsafeUnpin,

§

impl<B, const SIZE: usize> UnwindSafe for BlockDeviceAdapter<B, SIZE>
where B: UnwindSafe,

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.