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

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

Implementations§

source§

impl<'a> AsyncBufferSlice<'a>

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>) + Send + '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>

Synchronously and immediately map a buffer for reading. If the buffer is not immediately mappable through [BufferDescriptor::mapped_at_creation] or BufferSlice::map_async, will panic.

source

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

Synchronously and immediately map a buffer for writing. If the buffer is not immediately mappable through [BufferDescriptor::mapped_at_creation] or BufferSlice::map_async, will panic.

Trait Implementations§

source§

impl<'a, T> AsMut<T> for AsyncBufferSlice<'a>where <AsyncBufferSlice<'a> 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<'a, T> AsRef<T> for AsyncBufferSlice<'a>where T: ?Sized, <AsyncBufferSlice<'a> 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: Send,

source§

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

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

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

§

type Target = BufferSlice<'a>

The resulting type after dereferencing.
source§

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

Dereferences the value.
source§

impl<'a> DerefMut for AsyncBufferSlice<'a>

source§

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

Mutably dereferences the value.

Auto Trait Implementations§

§

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

impl<T> Downcast<T> for T

§

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

impl<T> Upcast<T> for T

§

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