LocalTask

Trait LocalTask 

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

A task that is executed on the local thread.

Unlike Task, the inner type does not need to be Send.

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: 'static> LocalTask<T> for LocalNeverTask<T>