Task

Trait Task 

Source
pub trait Task<T: Send + 'static>:
    Future<Output = T>
    + Send
    + 'static {
    // Required methods
    fn is_ready(&self) -> bool;
    fn take(&mut self) -> Option<T>;
}
Expand description

A task that can be spawned on a background thread.

The inner value requires to be Send and static.

Required Methods§

Source

fn is_ready(&self) -> bool

Returns if the task is finished or still pending.

Source

fn take(&mut self) -> Option<T>

Tries to take the inner value if the task is finished.

Returns None if the task is still pending.

This should only be called if you are sure the task is ready (check via Task::is_ready). Furthermore, calling this multiple times when the task is finished will probably raise a panic, so make sure to only call this once, if the task is finished.

Implementors§

Source§

impl<T: Send + 'static> Task<T> for NeverTask<T>