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§
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.
Sourcefn read_blocks(&mut self, lba: u32, buf: &mut [u8]) -> Result<(), Self::Error>
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().
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 dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".