Skip to main content

Task

Trait Task 

Source
pub trait Task: Future<Output = ()> {
    // Required method
    fn cancel<'async_trait>(
        self: Box<Self>,
    ) -> Pin<Box<dyn Future<Output = Option<()>> + 'async_trait>>
       where Self: 'async_trait;
}
Expand description

A common interface to wait for a Task completion, let it run n the background or cancel it.

Required Methods§

Source

fn cancel<'async_trait>( self: Box<Self>, ) -> Pin<Box<dyn Future<Output = Option<()>> + 'async_trait>>
where Self: 'async_trait,

Cancels the task and waits for it to stop running.

Returns the task’s output if it was completed just before it got canceled, or None if it didn’t complete.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§