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§
Required Methods§
sourcefn from_mut_world<'t>(
world: &'t mut World,
cx: &Self::Cx
) -> AccessResult<Self::RefMutCx<'t>>
fn from_mut_world<'t>( world: &'t mut World, cx: &Self::Cx ) -> AccessResult<Self::RefMutCx<'t>>
Obtain a borrow guard.
sourcefn from_mut_cx<'t>(
cx: &'t mut Self::RefMutCx<'_>,
cx: &Self::Cx
) -> AccessResult<Self::RefMut<'t>>
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§
sourcefn take(&self) -> AccessResult<Self::Generic>where
Self: AsyncTake,
fn take(&self) -> AccessResult<Self::Generic>where
Self: AsyncTake,
Remove and obtain the item from the world.
sourcefn take_on_load(&self) -> ChannelOut<AccessResult<Self::Generic>> ⓘ
fn take_on_load(&self) -> ChannelOut<AccessResult<Self::Generic>> ⓘ
Remove and obtain the item from the world once loaded.
sourcefn set<T>(&self, f: impl FnOnce(Self::RefMut<'_>) -> T) -> AccessResult<T>
fn set<T>(&self, f: impl FnOnce(Self::RefMut<'_>) -> T) -> AccessResult<T>
Run a function on this item and obtain the result.
sourcefn set_on_load<T: 'static>(
&self,
f: impl FnMut(Self::RefMut<'_>) -> T + 'static
) -> ChannelOut<AccessResult<T>> ⓘwhere
Self: AsyncLoad,
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.
sourcefn watch<T: 'static>(
&self,
f: impl FnMut(Self::RefMut<'_>) -> Option<T> + 'static
) -> ChannelOut<AccessResult<T>> ⓘ
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
.
sourcefn should_continue(err: AccessError) -> bool
fn should_continue(err: AccessError) -> bool
Continue watch
and on_load
if fetch context failed with these errors.
sourcefn exists(&self) -> boolwhere
Self: AsyncReadonlyAccess,
fn exists(&self) -> boolwhere
Self: AsyncReadonlyAccess,
Check if item exists.
sourcefn on_load(&self) -> MaybeChannelOut<()>where
Self: AsyncReadonlyAccess + AsyncLoad,
fn on_load(&self) -> MaybeChannelOut<()>where
Self: AsyncReadonlyAccess + AsyncLoad,
Wait until the item is loaded.
sourcefn get<T>(&self, f: impl FnOnce(Self::Ref<'_>) -> T) -> AccessResult<T>where
Self: AsyncReadonlyAccess,
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.
sourcefn get_on_load<T: 'static>(
&self,
f: impl FnOnce(Self::Ref<'_>) -> T + 'static
) -> MaybeChannelOut<AccessResult<T>>where
Self: AsyncReadonlyAccess + AsyncLoad,
fn get_on_load<T: 'static>(
&self,
f: impl FnOnce(Self::Ref<'_>) -> T + 'static
) -> MaybeChannelOut<AccessResult<T>>where
Self: AsyncReadonlyAccess + AsyncLoad,
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.
sourcefn cloned(&self) -> AccessResult<Self::Generic>
fn cloned(&self) -> AccessResult<Self::Generic>
Clone the item.
sourcefn clone_on_load(&self) -> MaybeChannelOut<AccessResult<Self::Generic>>
fn clone_on_load(&self) -> MaybeChannelOut<AccessResult<Self::Generic>>
Clone the item, repeat until the item is loaded.
sourcefn 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_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.
sourcefn 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 ⓘ
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();