pub struct MappedRange<'a, B: Backend> { /* private fields */ }
Expand description
Represents range of the memory mapped to the host. Provides methods for safer host access to the memory.
Implementations§
Source§impl<'a, B: Backend> MappedRange<'a, B>
impl<'a, B: Backend> MappedRange<'a, B>
Sourcepub fn ptr(&self) -> NonNull<u8>
pub fn ptr(&self) -> NonNull<u8>
Get pointer to beginning of memory region.
i.e. to range().start
offset from memory origin.
Sourcepub fn is_coherent(&self) -> bool
pub fn is_coherent(&self) -> bool
Return true if the mapped memory is coherent.
Sourcepub unsafe fn read<'b, T>(
&'b mut self,
device: &B::Device,
segment: Segment,
) -> Result<&'b [T], MapError>where
T: Copy,
'a: 'b,
pub unsafe fn read<'b, T>(
&'b mut self,
device: &B::Device,
segment: Segment,
) -> Result<&'b [T], MapError>where
T: Copy,
'a: 'b,
Fetch readable slice of sub-range to be read. Invalidating range if memory is not coherent.
§Safety
- Caller must ensure that device won’t write to the memory region until the borrowing ends.
T
Must be plain-old-data type compatible with data in mapped region.
Sourcepub unsafe fn write<'b, T>(
&'b mut self,
device: &'b B::Device,
segment: Segment,
) -> Result<Writer<'a, 'b, T, B>, MapError>where
T: Copy + 'b,
'a: 'b,
pub unsafe fn write<'b, T>(
&'b mut self,
device: &'b B::Device,
segment: Segment,
) -> Result<Writer<'a, 'b, T, B>, MapError>where
T: Copy + 'b,
'a: 'b,
Fetch writer to the sub-region. This writer will flush data on drop if written at least once.
§Safety
- Caller must ensure that device won’t write to or read from the memory region.
Trait Implementations§
Auto Trait Implementations§
impl<'a, B> Freeze for MappedRange<'a, B>
impl<'a, B> RefUnwindSafe for MappedRange<'a, B>
impl<'a, B> !Send for MappedRange<'a, B>
impl<'a, B> !Sync for MappedRange<'a, B>
impl<'a, B> Unpin for MappedRange<'a, B>
impl<'a, B> UnwindSafe for MappedRange<'a, B>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more