Struct AsyncBufferSlice

Source
pub struct AsyncBufferSlice<'a>
where Self: WasmNotSend,
{ /* private fields */ }
Expand description

A smart-pointer wrapper around a wgpu::BufferSlice, offering a map_async method than can be awaited.

Implementations§

Source§

impl AsyncBufferSlice<'_>

Source

pub fn map_async( &self, mode: MapMode, ) -> WgpuFuture<Result<(), BufferAsyncError>>

An awaitable version of [wgpu::Buffer::map_async].

Methods from Deref<Target = BufferSlice<'a>>§

Source

pub fn map_async( &self, mode: MapMode, callback: impl FnOnce(Result<(), BufferAsyncError>) + WasmNotSend + 'static, )

Map the buffer. Buffer is ready to map once the callback is called.

For the callback to complete, either queue.submit(..), instance.poll_all(..), or device.poll(..) must be called elsewhere in the runtime, possibly integrated into an event loop or run on a separate thread.

The callback will be called on the thread that first calls the above functions after the gpu work has completed. There are no restrictions on the code you can run in the callback, however on native the call to the function will not complete until the callback returns, so prefer keeping callbacks short and used to set flags, send messages, etc.

Source

pub fn get_mapped_range(&self) -> BufferView<'a>

Gain read-only access to the bytes of a mapped Buffer.

Return a BufferView referring to the buffer range represented by self. See the documentation for BufferView for details.

§Panics
  • This panics if the buffer to which self refers is not currently mapped.

  • If you try to create overlapping views of a buffer, mutable or otherwise, get_mapped_range will panic.

Source

pub fn get_mapped_range_mut(&self) -> BufferViewMut<'a>

Gain write access to the bytes of a mapped Buffer.

Return a BufferViewMut referring to the buffer range represented by self. See the documentation for BufferViewMut for more details.

§Panics
  • This panics if the buffer to which self refers is not currently mapped.

  • If you try to create overlapping views of a buffer, mutable or otherwise, get_mapped_range_mut will panic.

Trait Implementations§

Source§

impl<T> AsMut<T> for AsyncBufferSlice<'_>
where <Self as Deref>::Target: AsMut<T>,

Source§

fn as_mut(&mut self) -> &mut T

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl<T> AsRef<T> for AsyncBufferSlice<'_>
where T: ?Sized, <Self as Deref>::Target: AsRef<T>,

Source§

fn as_ref(&self) -> &T

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<'a> Debug for AsyncBufferSlice<'a>
where Self: WasmNotSend,

Source§

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

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

impl<'a> Deref for AsyncBufferSlice<'a>

Source§

type Target = BufferSlice<'a>

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl DerefMut for AsyncBufferSlice<'_>

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.

Auto Trait Implementations§

§

impl<'a> Freeze for AsyncBufferSlice<'a>

§

impl<'a> !RefUnwindSafe for AsyncBufferSlice<'a>

§

impl<'a> Send for AsyncBufferSlice<'a>

§

impl<'a> Sync for AsyncBufferSlice<'a>

§

impl<'a> Unpin for AsyncBufferSlice<'a>

§

impl<'a> !UnwindSafe for AsyncBufferSlice<'a>

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> Downcast<T> for T

Source§

fn downcast(&self) -> &T

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where 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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

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 T
where U: TryFrom<T>,

Source§

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.
Source§

impl<T> Upcast<T> for T

Source§

fn upcast(&self) -> Option<&T>

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,