pub trait Task<T>: Future<Output = T> + Send {
// Required method
fn cancel<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Option<T>> + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
}
Expand description
A common interface to wait for a Task completion, let it run n the background or cancel it.
Required Methods§
Sourcefn cancel<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Option<T>> + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn cancel<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Option<T>> + '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.