pub struct MemoryBlockDevice { /* private fields */ }Expand description
A block device backed by memory.
This is useful for testing and embedded scenarios where no persistent storage is available.
Implementations§
Source§impl MemoryBlockDevice
impl MemoryBlockDevice
Sourcepub fn with_size(size: u64) -> Self
pub fn with_size(size: u64) -> Self
Create a new in-memory block device with default block size (512 bytes).
Sourcepub fn as_mut_slice(&mut self) -> &mut [u8] ⓘ
pub fn as_mut_slice(&mut self) -> &mut [u8] ⓘ
Get the underlying data as a mutable slice.
Trait Implementations§
Source§impl BlockDevice for MemoryBlockDevice
impl BlockDevice for MemoryBlockDevice
Source§fn read_blocks(&self, block_id: u64, buf: &mut [u8]) -> Result<u32>
fn read_blocks(&self, block_id: u64, buf: &mut [u8]) -> Result<u32>
Read blocks from the device. Read more
Source§fn write_blocks(&mut self, block_id: u64, buf: &[u8]) -> Result<u32>
fn write_blocks(&mut self, block_id: u64, buf: &[u8]) -> Result<u32>
Write blocks to the device. Read more
Source§fn block_size(&self) -> u32
fn block_size(&self) -> u32
Get the physical block size in bytes.
Source§fn block_count(&self) -> u64
fn block_count(&self) -> u64
Get the total number of blocks.
Auto Trait Implementations§
impl Freeze for MemoryBlockDevice
impl RefUnwindSafe for MemoryBlockDevice
impl Send for MemoryBlockDevice
impl Sync for MemoryBlockDevice
impl Unpin for MemoryBlockDevice
impl UnsafeUnpin for MemoryBlockDevice
impl UnwindSafe for MemoryBlockDevice
Blanket Implementations§
Source§impl<T> BlockDeviceExt for Twhere
T: BlockDevice,
impl<T> BlockDeviceExt for Twhere
T: BlockDevice,
Source§fn total_size(&self) -> u64
fn total_size(&self) -> u64
Get the total size of the device in bytes.
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more