pub struct RamDisk { /* private fields */ }
Available on crate feature ramdisk only.
Expand description

A RAM disk that stores data in a vector.

Implementations§

source§

impl RamDisk

source

pub fn new(size_hint: usize) -> Self

Creates a new RAM disk with the given size hint.

The actual size of the RAM disk will be aligned upwards to the block size (512 bytes).

source

pub fn from(buf: &[u8]) -> Self

Creates a new RAM disk from the exiting data.

The actual size of the RAM disk will be aligned upwards to the block size (512 bytes).

source

pub const fn size(&self) -> usize

Returns the size of the RAM disk in bytes.

Trait Implementations§

source§

impl BaseDriverOps for RamDisk

source§

fn device_type(&self) -> DeviceType

The type of the device.
source§

fn device_name(&self) -> &str

The name of the device.
source§

impl BlockDriverOps for RamDisk

source§

fn num_blocks(&self) -> u64

The number of blocks in this storage device. Read more
source§

fn block_size(&self) -> usize

The size of each block in bytes.
source§

fn read_block(&mut self, block_id: u64, buf: &mut [u8]) -> DevResult

Reads blocked data from the given block. Read more
source§

fn write_block(&mut self, block_id: u64, buf: &[u8]) -> DevResult

Writes blocked data to the given block. Read more
source§

fn flush(&mut self) -> DevResult

Flushes the device to write all pending data to the storage.
source§

impl Default for RamDisk

source§

fn default() -> RamDisk

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. 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 Twhere 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, U> TryFrom<U> for Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.