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
impl IdentityDriverMem
Sourcepub fn new() -> IdentityDriverMem
pub fn new() -> IdentityDriverMem
Construct a new IdentityDriverMem
Sourcepub fn range_with_layout<'a>(
&'a self,
layout: Layout,
) -> Option<DeviceRange<'a>>
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.
Sourcepub fn new_range<'a>(&'a self, size_bytes: usize) -> Option<DeviceRange<'a>>
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.
Sourcepub fn alloc_queue_memory<'a>(
&'a self,
queue_size: u16,
) -> Option<QueueMemory<'a>>
pub fn alloc_queue_memory<'a>( &'a self, queue_size: u16, ) -> Option<QueueMemory<'a>>
Allocates ranges to fill and return a QueueMemory