pub trait UiFutureExt: Future + Sized {
// Provided methods
fn pend_after<T>(self) -> PendAfter<Self, T> { ... }
fn meanwhile<F: Future>(
self,
effect: F,
) -> <(Self, PendAfter<F, Self::Output>) as Race>::Future { ... }
}Expand description
Provides Future extension methods useful for writing UI.
Implemented for every Future type.
Provided Methods§
Sourcefn pend_after<T>(self) -> PendAfter<Self, T>
fn pend_after<T>(self) -> PendAfter<Self, T>
Turn the given future into one that never finishes.
You can specify the output type of the output future to be anything, because the future will never produce output.
use async_ui_web_core::combinators::UiFutureExt;
let fut = my_async_fn().pend_after::<std::convert::Infallible>();
fut.await; // will never finishf.pend_after() is equivalent to
async {
f.await;
std::future::pending().await
}Sourcefn meanwhile<F: Future>(
self,
effect: F,
) -> <(Self, PendAfter<F, Self::Output>) as Race>::Future
fn meanwhile<F: Future>( self, effect: F, ) -> <(Self, PendAfter<F, Self::Output>) as Race>::Future
Run some Future while this one is running.
f.meanwhile(g) is equivalent to
race((
f,
g.pend_after()
))Use this to display UI as side-effect of some async execution.
For example, load_data().meanwhile(spinner()).await.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.