virtio_device::fake_queue

Struct IdentityDriverMem

Source
pub struct IdentityDriverMem { /* private fields */ }
Expand description

Implementation of crate::mem::DriverMem assuming the identity translation.

Can be used to allocate valid DeviceRange using the [range_with_layout] or [new_range] methods. This then implements the identity transformation in [translate] meaning that:

let range = identity_driver_mem.new_range(64)?;
assert_eq!(identity_driver_mem.translate(range.get().into()), Some(range)

There is no mechanism to free or deallocate any constructed ranges, this is neccessary to ensure they remain valid their provided lifetimes. Allocations will be freed once the IdentityDriverMem is dropped.

Implementations§

Source§

impl IdentityDriverMem

Source

pub fn new() -> IdentityDriverMem

Construct a new IdentityDriverMem

Source

pub fn range_with_layout<'a>( &'a self, layout: Layout, ) -> Option<DeviceRange<'a>>

Allocate with a specific alloc::Layout

Specifying a specific alloc::Layout for the range is to allow for alignments to be specified so that underlying DeviceRange can be accessed directly as a desired object using DeviceRange::try_ptr.

The allocated range will be zeroed.

Source

pub fn new_range<'a>(&'a self, size_bytes: usize) -> Option<DeviceRange<'a>>

Allocate a range to hold size_bytes

The backing allocation will be aligned to match a u64, but the DeviceRange reported by get will be exactly size_bytes long.

The allocated range will be zeroed.

Source

pub fn alloc_queue_memory<'a>( &'a self, queue_size: u16, ) -> Option<QueueMemory<'a>>

Allocates ranges to fill and return a QueueMemory

Trait Implementations§

Source§

impl DriverMem for IdentityDriverMem

Source§

fn translate<'a>(&'a self, driver: DriverRange) -> Option<DeviceRange<'a>>

Attempt to turn a DriverRange into a DeviceRange. Read more

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.