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

§

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

§

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.