pub struct GpuMappedBuffer<'a> { /* private fields */ }Expand description
GPU-visible memory region that io_uring is allowed to DMA into.
Compatibility constructors cover host-visible shared mappings. The BAR1 constructor covers the native GPUDirect path where NVMe DMA lands directly in GPU-owned memory.
Implementations§
Source§impl<'a> GpuMappedBuffer<'a>
impl<'a> GpuMappedBuffer<'a>
Sourcepub unsafe fn from_host_visible_slice(slice: &'a mut [u8]) -> Self
pub unsafe fn from_host_visible_slice(slice: &'a mut [u8]) -> Self
Construct from a borrowed host-visible byte slice.
§Safety
The caller asserts:
slicealiases a device allocation created with host-visible host-shared usage bits by the concrete backend.- No other code reads or writes through
slicewhile the returned handle is alive.
Sourcepub unsafe fn from_host_visible_owner<O: ?Sized>(
_owner: &'a mut O,
ptr: *mut u8,
len: usize,
) -> Self
pub unsafe fn from_host_visible_owner<O: ?Sized>( _owner: &'a mut O, ptr: *mut u8, len: usize, ) -> Self
Construct from a raw pointer plus an explicit owner anchor.
The borrow on owner forces the mapped region to outlive every derived AsyncUringStream.
§Safety
The caller must ensure that ptr names a len-byte host-visible GPU allocation owned by owner, and that no other code accesses the region while the returned handle is alive.
Sourcepub unsafe fn duplicate(&self) -> Self
pub unsafe fn duplicate(&self) -> Self
Duplicate the mapped-buffer handle for the same underlying region.
§Safety
The caller must uphold the same aliasing and lifetime guarantees as
GpuMappedBuffer::from_host_visible_slice. This does not clone memory;
it creates another handle to the same mapped bytes.
Sourcepub fn sub_region(
&self,
offset: usize,
len: usize,
) -> Result<Self, PipelineError>
pub fn sub_region( &self, offset: usize, len: usize, ) -> Result<Self, PipelineError>
Carve out a sub-region of this mapped buffer.
This preserves the original constructor contract: the returned handle aliases the same host-visible GPU allocation and carries no ownership of its own.
§Errors
Returns PipelineError::QueueFull when offset + len
exceeds the mapped buffer bounds.
Sourcepub unsafe fn as_mut_slice(&mut self) -> &mut [u8] ⓘ
pub unsafe fn as_mut_slice(&mut self) -> &mut [u8] ⓘ
Borrow the mapped bytes as a mutable slice.
§Safety
The caller must ensure exclusive mutable access to the region for the lifetime of the returned slice.
Sourcepub unsafe fn from_bar1_peer_with_owner<O: ?Sized>(
_owner: &'a mut O,
peer_ptr: *mut u8,
len: usize,
) -> Self
pub unsafe fn from_bar1_peer_with_owner<O: ?Sized>( _owner: &'a mut O, peer_ptr: *mut u8, len: usize, ) -> Self
Construct from a PCIe peer-memory pointer for direct storage DMA.
§Safety
The caller must ensure that peer_ptr names a GPU allocation suitable for peer DMA, that the allocation outlives the handle, and that the io_uring kernel and storage driver both support DMA mapping.