pub trait AsyncBlockDevice {
type Error;
// Required methods
fn block_size(&self) -> u32;
fn block_count(&self) -> u32;
async fn read_blocks(
&mut self,
lba: u32,
buf: &mut [u8],
) -> Result<(), Self::Error>;
async fn write_blocks(
&mut self,
lba: u32,
data: &[u8],
) -> Result<(), Self::Error>;
async fn flush(&mut self) -> Result<(), Self::Error>;
// Provided method
fn is_write_protected(&self) -> bool { ... }
}Expand description
Async block device abstraction used by MscClass.
You can implement this trait directly for asynchronous storage, or
implement BlockDevice and rely on the blanket adapter.
Required Associated Types§
Required Methods§
Sourcefn block_size(&self) -> u32
fn block_size(&self) -> u32
Returns the block size in bytes.
Sourcefn block_count(&self) -> u32
fn block_count(&self) -> u32
Returns the total amount of logical blocks.
Sourceasync fn read_blocks(
&mut self,
lba: u32,
buf: &mut [u8],
) -> Result<(), Self::Error>
async 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(). Transferring
several blocks per call lets storage use multi-block commands.
Provided Methods§
Sourcefn is_write_protected(&self) -> bool
fn is_write_protected(&self) -> bool
Returns whether the media is write-protected.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementors§
Source§impl<'a, D: AsyncBlockDevice> AsyncBlockDevice for SectorCache<'a, D>
impl<'a, D: AsyncBlockDevice> AsyncBlockDevice for SectorCache<'a, D>
type Error = <D as AsyncBlockDevice>::Error
Source§impl<B: BlockDevice<SIZE>, const SIZE: usize> AsyncBlockDevice for BlockDeviceAdapter<B, SIZE>
Available on crate feature block-device-driver only.
impl<B: BlockDevice<SIZE>, const SIZE: usize> AsyncBlockDevice for BlockDeviceAdapter<B, SIZE>
Available on crate feature
block-device-driver only.