cm_util::abortable_scope

Trait AbortFutureExt

Source
pub trait AbortFutureExt<T>: Future<Output = T> + Send {
    // Required method
    fn with(
        self,
        scope: &AbortableScope,
    ) -> impl Future<Output = Result<T, AbortError>>;
}

Required Methods§

Source

fn with( self, scope: &AbortableScope, ) -> impl Future<Output = Result<T, AbortError>>

Causes the future to complete with an [InterruptError] if the scope is aborted.

Syntax sugar for scope.run(future):

let (scope, handle) = AbortableScope::new();
handle.abort();
some_future.with(&scope).await;   // Result<T, InterruptError>

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.

Implementors§

Source§

impl<Fut, T> AbortFutureExt<T> for Fut
where Fut: Future<Output = T> + Send,