Skip to main content

MemoryDevice

Struct MemoryDevice 

Source
pub struct MemoryDevice {
    pub bytes: Vec<u8>,
    pub label: String,
}
Expand description

In-memory Device impl used by unit tests. Backed by a Vec<u8>.

Fields§

§bytes: Vec<u8>§label: String

Implementations§

Source§

impl MemoryDevice

Source

pub fn new(size: u64) -> Self

Trait Implementations§

Source§

impl Device for MemoryDevice

Source§

fn size_bytes(&self) -> Result<u64>

Total addressable bytes of the underlying device.
Source§

fn read_at(&mut self, offset: u64, buf: &mut [u8]) -> Result<()>

Read exactly buf.len() bytes at offset. Errors if read short.
Source§

fn write_at(&mut self, offset: u64, buf: &[u8]) -> Result<()>

Write exactly buf.len() bytes at offset. Errors if write short.
Source§

fn sync(&mut self) -> Result<()>

Force any buffered writes to the physical medium.
Source§

fn describe(&self) -> String

Human-readable identifier for log messages and the confirm prompt. e.g. “/dev/rdisk8 (64 GB SanDisk Cruzer)” or “in-memory test device”.

Auto Trait Implementations§

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