pub struct MappingState { /* private fields */ }
Expand description

Represents the currently host-mapped region of a DeviceMemory block.

Implementations§

source§

impl MappingState

source

pub fn ptr(&self) -> NonNull<c_void>

Returns the pointer to the start of the mapped memory. Meaning that the pointer is already offset by the offset.

source

pub fn offset(&self) -> DeviceSize

Returns the offset given to DeviceMemory::map.

source

pub fn size(&self) -> DeviceSize

Returns the size given to DeviceMemory::map.

source

pub fn slice(&self, range: Range<DeviceSize>) -> Option<NonNull<[u8]>>

Returns a pointer to a slice of the mapped memory. Returns None if out of bounds.

range is specified in bytes relative to the start of the memory allocation, and must fall within the range of the memory mapping given to DeviceMemory::map.

This function is safe in the sense that the returned pointer is guaranteed to be within bounds of the mapped memory, however dereferencing the pointer isn’t:

  • Normal Rust aliasing rules apply: if you create a mutable reference out of the pointer, you must ensure that no other references exist in Rust to any portion of the same memory.
  • While a reference created from the pointer exists, there must be no operations pending or executing in any queue on the device, that write to any portion of the same memory.
  • While a mutable reference created from the pointer exists, there must be no operations pending or executing in any queue on the device, that read from any portion of the same memory.

Trait Implementations§

source§

impl Debug for MappingState

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Send for MappingState

source§

impl Sync for MappingState

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere 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 Twhere 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.