Skip to main content

RamDisk

Struct RamDisk 

Source
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: AccessStats

Implementations§

Source§

impl<const BLOCK_SIZE: usize, const WRITE_SIZE: usize> RamDisk<BLOCK_SIZE, WRITE_SIZE>

Source

pub fn new(blocks: usize) -> Self

Source

pub fn new_erased(blocks: usize) -> Self

Source

pub fn clear_stats(&mut self)

Trait Implementations§

Source§

impl<const BLOCK_SIZE: usize, const WRITE_SIZE: usize> AsMut<RamDisk<BLOCK_SIZE, WRITE_SIZE>> for RamDisk<BLOCK_SIZE, WRITE_SIZE>

Source§

fn as_mut(&mut self) -> &mut Self

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl<const BLOCK_SIZE: usize, const WRITE_SIZE: usize> Clone for RamDisk<BLOCK_SIZE, WRITE_SIZE>

Source§

fn clone(&self) -> RamDisk<BLOCK_SIZE, WRITE_SIZE>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<const BLOCK_SIZE: usize, const WRITE_SIZE: usize> Debug for RamDisk<BLOCK_SIZE, WRITE_SIZE>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

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

The size of an erasable block in bytes.
Source§

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>

Reads data from the disk into the buffer. Read more
Source§

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>

Erases the block at the given block index. Read more
Source§

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>>

Reads the exact number of bytes required to fill the buffer. Read more
Source§

fn write_all(&mut self, offset: usize, buf: &[u8]) -> Result<(), Self::Error>

Writes the exact number of bytes from the buffer to the disk. Read more
Source§

impl<const BLOCK_SIZE: usize, const WRITE_SIZE: usize> ErrorType for RamDisk<BLOCK_SIZE, WRITE_SIZE>

Source§

type Error = Infallible

Error type of all the IO operations on this type.

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> 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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.