DeferAsync

Trait DeferAsync 

Source
pub trait DeferAsync<T> {
    // Required method
    fn defer_async<R>(
        self,
        f: impl AsyncDeferCallback<T, R>,
    ) -> impl Future<Output = Option<R>> + Send
       where R: Send + 'static,
             Self: Sized;
}
Expand description

Async extension to [UiRunner], allowing to await until deferred closures are executed.

Required Methods§

Source

fn defer_async<R>( self, f: impl AsyncDeferCallback<T, R>, ) -> impl Future<Output = Option<R>> + Send
where R: Send + 'static, Self: Sized,

Awaitable variant of [UiRunner::defer].

This is actually similar to [UiRunner::block_on], but can be used inside async contexts where is important to not block.

The syncrhonous return value of the closure will be returned from the Future.

The Future may give None if it couldn’t receive a value back, because the widget coudln’t execute the closure. This can happen even without errors if the widget is dropped before executing the pending closure.

Implementations on Foreign Types§

Source§

impl<T: 'static> DeferAsync<T> for UiRunner<T>

Source§

async fn defer_async<R: Send + 'static>( self, f: impl AsyncDeferCallback<T, R>, ) -> Option<R>

Implementors§