mz_ore::future

Trait OreFutureExt

Source
pub trait OreFutureExt {
    // Required methods
    fn spawn_if_canceled<Name, NameClosure>(
        self,
        nc: NameClosure,
    ) -> SpawnIfCanceled<Self::Output, Name, NameClosure> 
       where Name: AsRef<str>,
             NameClosure: FnOnce() -> Name + Unpin,
             Self: Future + Send + 'static,
             Self::Output: Send + 'static;
    fn run_in_task<'async_trait, Name, NameClosure>(
        self,
        nc: NameClosure,
    ) -> Pin<Box<dyn Future<Output = Self::Output> + Send + 'async_trait>>
       where Name: AsRef<str> + 'async_trait,
             NameClosure: FnOnce() -> Name + Unpin + Send + 'async_trait,
             Self: Future + Send + 'static + 'async_trait,
             Self::Output: Send + 'static;
    fn run_in_task_if<'async_trait, Name, NameClosure>(
        self,
        in_task: InTask,
        nc: NameClosure,
    ) -> Pin<Box<dyn Future<Output = Self::Output> + Send + 'async_trait>>
       where Name: AsRef<str> + 'async_trait,
             NameClosure: FnOnce() -> Name + Unpin + Send + 'async_trait,
             Self: Future + Send + 'static + 'async_trait,
             Self::Output: Send + 'static;
    fn ore_catch_unwind(self) -> OreCatchUnwind<Self> 
       where Self: Sized + UnwindSafe;
}
Available on crate feature async only.
Expand description

Extension methods for futures.

Required Methods§

Source

fn spawn_if_canceled<Name, NameClosure>( self, nc: NameClosure, ) -> SpawnIfCanceled<Self::Output, Name, NameClosure>
where Name: AsRef<str>, NameClosure: FnOnce() -> Name + Unpin, Self: Future + Send + 'static, Self::Output: Send + 'static,

Wraps a future in a SpawnIfCanceled future, which will spawn a task to poll the inner future to completion if it is dropped.

Source

fn run_in_task<'async_trait, Name, NameClosure>( self, nc: NameClosure, ) -> Pin<Box<dyn Future<Output = Self::Output> + Send + 'async_trait>>
where Name: AsRef<str> + 'async_trait, NameClosure: FnOnce() -> Name + Unpin + Send + 'async_trait, Self: Future + Send + 'static + 'async_trait, Self::Output: Send + 'static,

Run a 'static future in a Tokio task, naming that task, using a convenient postfix call notation.

Useful in contexts where futures may be starved and cause inadvertent failures in I/O-sensitive operations, such as when called within timely operators.

Source

fn run_in_task_if<'async_trait, Name, NameClosure>( self, in_task: InTask, nc: NameClosure, ) -> Pin<Box<dyn Future<Output = Self::Output> + Send + 'async_trait>>
where Name: AsRef<str> + 'async_trait, NameClosure: FnOnce() -> Name + Unpin + Send + 'async_trait, Self: Future + Send + 'static + 'async_trait, Self::Output: Send + 'static,

The same as run_in_task, but allows the callee to dynamically choose whether or not the future is polled into a Tokio task.

Source

fn ore_catch_unwind(self) -> OreCatchUnwind<Self>
where Self: Sized + UnwindSafe,

Like FutureExt::catch_unwind, but can unwind panics even if panic::install_enhanced_handler has been called.

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<T> OreFutureExt for T
where T: Future,