TaskImpl

Trait TaskImpl 

Source
pub trait TaskImpl:
    Future
    + Send
    + Unpin
    + 'static {
    // Provided methods
    fn cancel<'life0, 'async_trait>(
        &'life0 mut self,
    ) -> Pin<Box<dyn Future<Output = Option<<Self as Future>::Output>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait { ... }
    fn detach(&mut self)
       where Self: Sized { ... }
}
Expand description

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

Provided Methods§

Source

fn cancel<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = Option<<Self as Future>::Output>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: '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.

Source

fn detach(&mut self)
where Self: Sized,

“Detach” the task from the current context to let it run in the background.

Note that this is automatically called when dropping the Task so that it doesn’t get canceled.

Implementors§