pub struct BufferMapping { /* private fields */ }Expand description
Represents a mapped range in the buffer.
While returned BufferMapping is alive, Buffer::destroy and Buffer::unmap calls will block until BufferMapping is dropped.
Implementations§
Source§impl BufferMapping
impl BufferMapping
Sourcepub fn ptr(&self) -> NonNull<u8>
pub fn ptr(&self) -> NonNull<u8>
§How to safely use the pointer
- Pointer is only accessed for the length returned by
BufferMapping::len. - Pointer is only accessed while
BufferMappingis alive. - Reading is allowed if
BufferMapping::modeisMapMode::Read(buffer haswgt::BufferUsages::MAP_READset). - Writing is allowed if
BufferMapping::modeisMapMode::Write(buffer haswgt::BufferUsages::MAP_WRITEset). - Atomics must not be used through the pointer since read-modify-write operations may not function on write-combining memory. This also means that it’s not safe to create mutable rust references from this pointer since rust’s memory model requires atomic operations to work.
pub fn mode(&self) -> MapMode
pub fn len(&self) -> u64
Sourcepub fn read_slice(&self) -> &[u8] ⓘ
pub fn read_slice(&self) -> &[u8] ⓘ
Returns a read-only slice to the mapped buffer.
BufferMapping::mode must be MapMode::Read (buffer has wgt::BufferUsages::MAP_READ set) otherwise it will panic.
Sourcepub fn write_slice(&self) -> WriteOnly<'_, [u8]>
pub fn write_slice(&self) -> WriteOnly<'_, [u8]>
Returns a write-only slice to the mapped buffer.
BufferMapping::mode must be MapMode::Write (buffer has wgt::BufferUsages::MAP_WRITE set) otherwise it will panic.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for BufferMapping
impl !Send for BufferMapping
impl !Sync for BufferMapping
impl !UnwindSafe for BufferMapping
impl Forget for BufferMapping
impl Freeze for BufferMappingwhere
*const u8 is !null: Freeze,
&'static RwLock<RawRwLock, BufferMapState>: Freeze,
PhantomData<(&'static BufferMapState, GuardNoSend)>: Freeze,
*const ArcInner<RwLock<BufferMapState>> is !null: Freeze,
PhantomData<ArcInner<RwLock<BufferMapState>>>: Freeze,
impl Move for BufferMapping
impl Unpin for BufferMapping
impl UnsafeUnpin for BufferMappingwhere
*const u8 is !null: UnsafeUnpin,
&'static RwLock<RawRwLock, BufferMapState>: UnsafeUnpin,
PhantomData<(&'static BufferMapState, GuardNoSend)>: UnsafeUnpin,
*const ArcInner<RwLock<BufferMapState>> is !null: UnsafeUnpin,
PhantomData<ArcInner<RwLock<BufferMapState>>>: UnsafeUnpin,
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