Trait bevy_defer::access::traits::AsyncAccess

source ·
pub trait AsyncAccess {
    type Cx: 'static;
    type RefMutCx<'t>;
    type Ref<'t>;
    type RefMut<'t>;

Show 17 methods // Required methods fn as_cx(&self) -> Self::Cx; fn from_mut_world<'t>( world: &'t mut World, cx: &Self::Cx ) -> AccessResult<Self::RefMutCx<'t>>; fn from_mut_cx<'t>( cx: &'t mut Self::RefMutCx<'_>, cx: &Self::Cx ) -> AccessResult<Self::RefMut<'t>>; // Provided methods fn take(&self) -> AccessResult<Self::Generic> where Self: AsyncTake { ... } fn take_on_load(&self) -> ChannelOut<AccessResult<Self::Generic>> where Self: AsyncTake + AsyncLoad { ... } fn set<T>(&self, f: impl FnOnce(Self::RefMut<'_>) -> T) -> AccessResult<T> { ... } fn set_on_load<T: 'static>( &self, f: impl FnMut(Self::RefMut<'_>) -> T + 'static ) -> ChannelOut<AccessResult<T>> where Self: AsyncLoad { ... } fn watch<T: 'static>( &self, f: impl FnMut(Self::RefMut<'_>) -> Option<T> + 'static ) -> ChannelOut<AccessResult<T>> { ... } fn should_continue(err: AccessError) -> bool { ... } fn exists(&self) -> bool where Self: AsyncReadonlyAccess { ... } fn on_load(&self) -> MaybeChannelOut<()> where Self: AsyncReadonlyAccess + AsyncLoad { ... } fn get<T>(&self, f: impl FnOnce(Self::Ref<'_>) -> T) -> AccessResult<T> where Self: AsyncReadonlyAccess { ... } fn get_on_load<T: 'static>( &self, f: impl FnOnce(Self::Ref<'_>) -> T + 'static ) -> MaybeChannelOut<AccessResult<T>> where Self: AsyncReadonlyAccess + AsyncLoad { ... } fn cloned(&self) -> AccessResult<Self::Generic> where Self: AsyncAccessRef, Self::Generic: Clone { ... } fn clone_on_load(&self) -> MaybeChannelOut<AccessResult<Self::Generic>> where Self: AsyncAccessRef + AsyncLoad, Self::Generic: Clone { ... } fn interpolate_to<V: Lerp>( &self, to: V, get: impl FnMut(Self::Ref<'_>) -> V + Send + 'static, set: impl FnMut(Self::RefMut<'_>, V) + Send + 'static, curve: impl FnMut(f32) -> f32 + Send + 'static, duration: impl AsSeconds, cancel: impl Into<TaskCancellation> ) -> InterpolateOut where Self: AsyncAccessRef { ... } fn interpolate<V>( &self, span: impl FnMut(f32) -> V + 'static, write: impl FnMut(Self::RefMut<'_>, V) + 'static, curve: impl FnMut(f32) -> f32 + 'static, duration: impl AsSeconds, playback: Playback, cancel: impl Into<TaskCancellation> ) -> InterpolateOut { ... }
}
Expand description

Provides functionalities for async accessors.

Required Associated Types§

source

type Cx: 'static

Static information, usually Entity or Handle.

source

type RefMutCx<'t>

Optional borrow guard for mutable access.

source

type Ref<'t>

Reference for immutable access.

source

type RefMut<'t>

Reference for mutable access.

Required Methods§

source

fn as_cx(&self) -> Self::Cx

Obtain Cx.

source

fn from_mut_world<'t>( world: &'t mut World, cx: &Self::Cx ) -> AccessResult<Self::RefMutCx<'t>>

Obtain a borrow guard.

source

fn from_mut_cx<'t>( cx: &'t mut Self::RefMutCx<'_>, cx: &Self::Cx ) -> AccessResult<Self::RefMut<'t>>

Obtain a mutable reference from the borrow guard.

Provided Methods§

source

fn take(&self) -> AccessResult<Self::Generic>
where Self: AsyncTake,

Remove and obtain the item from the world.

source

fn take_on_load(&self) -> ChannelOut<AccessResult<Self::Generic>>
where Self: AsyncTake + AsyncLoad,

Remove and obtain the item from the world once loaded.

source

fn set<T>(&self, f: impl FnOnce(Self::RefMut<'_>) -> T) -> AccessResult<T>

Run a function on this item and obtain the result.

source

fn set_on_load<T: 'static>( &self, f: impl FnMut(Self::RefMut<'_>) -> T + 'static ) -> ChannelOut<AccessResult<T>>
where Self: AsyncLoad,

Run a function on this item and obtain the result once loaded.

source

fn watch<T: 'static>( &self, f: impl FnMut(Self::RefMut<'_>) -> Option<T> + 'static ) -> ChannelOut<AccessResult<T>>

Run a function on this item until it returns Some.

source

fn should_continue(err: AccessError) -> bool

Continue watch and on_load if fetch context failed with these errors.

source

fn exists(&self) -> bool
where Self: AsyncReadonlyAccess,

Check if item exists.

source

fn on_load(&self) -> MaybeChannelOut<()>

Wait until the item is loaded.

source

fn get<T>(&self, f: impl FnOnce(Self::Ref<'_>) -> T) -> AccessResult<T>
where Self: AsyncReadonlyAccess,

Run a function on a readonly reference to this item and obtain the result.

Completes immediately if &World access is available.

source

fn get_on_load<T: 'static>( &self, f: impl FnOnce(Self::Ref<'_>) -> T + 'static ) -> MaybeChannelOut<AccessResult<T>>

Run a function on a readonly reference to this item and obtain the result, repeat until the item is loaded.

Completes immediately if &World access is available and item is loaded.

source

fn cloned(&self) -> AccessResult<Self::Generic>
where Self: AsyncAccessRef, Self::Generic: Clone,

Clone the item.

source

fn clone_on_load(&self) -> MaybeChannelOut<AccessResult<Self::Generic>>
where Self: AsyncAccessRef + AsyncLoad, Self::Generic: Clone,

Clone the item, repeat until the item is loaded.

source

fn interpolate_to<V: Lerp>( &self, to: V, get: impl FnMut(Self::Ref<'_>) -> V + Send + 'static, set: impl FnMut(Self::RefMut<'_>, V) + Send + 'static, curve: impl FnMut(f32) -> f32 + Send + 'static, duration: impl AsSeconds, cancel: impl Into<TaskCancellation> ) -> InterpolateOut
where Self: AsyncAccessRef,

Interpolate to a new value from the previous value.

source

fn interpolate<V>( &self, span: impl FnMut(f32) -> V + 'static, write: impl FnMut(Self::RefMut<'_>, V) + 'static, curve: impl FnMut(f32) -> f32 + 'static, duration: impl AsSeconds, playback: Playback, cancel: impl Into<TaskCancellation> ) -> InterpolateOut

Run an animation, maybe repeatedly, that can be cancelled.

It is recommended to spawn the result instead of awaiting it directly if not Playback::Once.

spawn(interpolate(.., Playback::Loop, &cancel));
cancel.cancel();

Object Safety§

This trait is not object safe.

Implementors§

source§

impl<A: Asset> AsyncAccess for AsyncAsset<A>

§

type Cx = Handle<A>

§

type RefMutCx<'t> = &'t mut A

§

type Ref<'t> = &'t A

§

type RefMut<'t> = &'t mut A

source§

impl<C: Component> AsyncAccess for AsyncComponent<C>

§

type Cx = Entity

§

type RefMutCx<'t> = &'t mut C

§

type Ref<'t> = &'t C

§

type RefMut<'t> = &'t mut C

source§

impl<D: QueryData + 'static, F: QueryFilter + 'static> AsyncAccess for AsyncEntityQuery<D, F>

§

type Cx = Entity

§

type RefMutCx<'t> = OwnedQueryState<'t, D, F>

§

type Ref<'t> = <<D as QueryData>::ReadOnly as WorldQuery>::Item<'t>

§

type RefMut<'t> = <D as WorldQuery>::Item<'t>

source§

impl<D: QueryData + 'static, F: QueryFilter + 'static> AsyncAccess for AsyncQuery<D, F>

§

type Cx = ()

§

type RefMutCx<'t> = Option<OwnedQueryState<'t, D, F>>

§

type Ref<'t> = OwnedQueryState<'t, D, F>

§

type RefMut<'t> = OwnedQueryState<'t, D, F>

source§

impl<D: QueryData + 'static, F: QueryFilter + 'static> AsyncAccess for AsyncQuerySingle<D, F>

§

type Cx = ()

§

type RefMutCx<'t> = OwnedQueryState<'t, D, F>

§

type Ref<'t> = <<D as QueryData>::ReadOnly as WorldQuery>::Item<'t>

§

type RefMut<'t> = <D as WorldQuery>::Item<'t>

source§

impl<R: 'static> AsyncAccess for AsyncNonSend<R>

§

type Cx = ()

§

type RefMutCx<'t> = &'t mut R

§

type Ref<'t> = &'t R

§

type RefMut<'t> = &'t mut R

source§

impl<R: Resource> AsyncAccess for AsyncResource<R>

§

type Cx = ()

§

type RefMutCx<'t> = &'t mut R

§

type Ref<'t> = &'t R

§

type RefMut<'t> = &'t mut R