pub struct RamDisk<const BLOCK_SIZE: usize, const WRITE_SIZE: usize> {
pub data: Box<[u8]>,
pub stats: AccessStats,
}Expand description
A simple in-memory disk.
Used for testing and debugging.
Fields§
§data: Box<[u8]>§stats: AccessStatsImplementations§
Trait Implementations§
Source§impl<const BLOCK_SIZE: usize, const WRITE_SIZE: usize> AsMut<RamDisk<BLOCK_SIZE, WRITE_SIZE>> for RamDisk<BLOCK_SIZE, WRITE_SIZE>
impl<const BLOCK_SIZE: usize, const WRITE_SIZE: usize> AsMut<RamDisk<BLOCK_SIZE, WRITE_SIZE>> for RamDisk<BLOCK_SIZE, WRITE_SIZE>
Source§impl<const BLOCK_SIZE: usize, const WRITE_SIZE: usize> Clone for RamDisk<BLOCK_SIZE, WRITE_SIZE>
impl<const BLOCK_SIZE: usize, const WRITE_SIZE: usize> Clone for RamDisk<BLOCK_SIZE, WRITE_SIZE>
Source§impl<const BLOCK_SIZE: usize, const WRITE_SIZE: usize> Debug for RamDisk<BLOCK_SIZE, WRITE_SIZE>
impl<const BLOCK_SIZE: usize, const WRITE_SIZE: usize> Debug for RamDisk<BLOCK_SIZE, WRITE_SIZE>
Source§impl<const BLOCK_SIZE: usize, const WRITE_SIZE: usize> Disk for RamDisk<BLOCK_SIZE, WRITE_SIZE>where
Const<WRITE_SIZE>: IntoArrayLength,
impl<const BLOCK_SIZE: usize, const WRITE_SIZE: usize> Disk for RamDisk<BLOCK_SIZE, WRITE_SIZE>where
Const<WRITE_SIZE>: IntoArrayLength,
Source§const ERASE_BLOCK_SIZE: usize = BLOCK_SIZE
const ERASE_BLOCK_SIZE: usize = BLOCK_SIZE
The size of an erasable block in bytes.
Source§type WRITE_GRANULARITY = <Const<WRITE_SIZE> as IntoArrayLength>::ArrayLength
type WRITE_GRANULARITY = <Const<WRITE_SIZE> as IntoArrayLength>::ArrayLength
The minimum size of a write operation in bytes. Read more
Source§fn read(&mut self, offset: usize, buf: &mut [u8]) -> Result<usize, Self::Error>
fn read(&mut self, offset: usize, buf: &mut [u8]) -> Result<usize, Self::Error>
Reads data from the disk into the buffer. Read more
Source§fn write(&mut self, offset: usize, buf: &[u8]) -> Result<usize, Self::Error>
fn write(&mut self, offset: usize, buf: &[u8]) -> Result<usize, Self::Error>
Writes data from the buffer to the disk. Read more
Source§fn erase(&mut self, block: usize) -> Result<(), Self::Error>
fn erase(&mut self, block: usize) -> Result<(), Self::Error>
Erases the block at the given block index. Read more
Source§fn block_count(&self) -> usize
fn block_count(&self) -> usize
Returns the number of blocks on the disk. Read more
Source§fn read_exact(
&mut self,
offset: usize,
buf: &mut [u8],
) -> Result<(), ReadExactError<Self::Error>>
fn read_exact( &mut self, offset: usize, buf: &mut [u8], ) -> Result<(), ReadExactError<Self::Error>>
Reads the exact number of bytes required to fill the buffer. Read more
Auto Trait Implementations§
impl<const BLOCK_SIZE: usize, const WRITE_SIZE: usize> Freeze for RamDisk<BLOCK_SIZE, WRITE_SIZE>
impl<const BLOCK_SIZE: usize, const WRITE_SIZE: usize> RefUnwindSafe for RamDisk<BLOCK_SIZE, WRITE_SIZE>
impl<const BLOCK_SIZE: usize, const WRITE_SIZE: usize> Send for RamDisk<BLOCK_SIZE, WRITE_SIZE>
impl<const BLOCK_SIZE: usize, const WRITE_SIZE: usize> Sync for RamDisk<BLOCK_SIZE, WRITE_SIZE>
impl<const BLOCK_SIZE: usize, const WRITE_SIZE: usize> Unpin for RamDisk<BLOCK_SIZE, WRITE_SIZE>
impl<const BLOCK_SIZE: usize, const WRITE_SIZE: usize> UnsafeUnpin for RamDisk<BLOCK_SIZE, WRITE_SIZE>
impl<const BLOCK_SIZE: usize, const WRITE_SIZE: usize> UnwindSafe for RamDisk<BLOCK_SIZE, WRITE_SIZE>
Blanket Implementations§
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