[][src]Struct suspend::Task

#[must_use = "Task must be awaited"]pub struct Task<'t, T> { /* fields omitted */ }

An asynchronous result which may be evaluated with .await, or by using blocking operations with an optional timeout.

Implementations

impl<'t, T> Task<'t, T>[src]

pub fn from_poll<F>(f: F) -> Self where
    F: FnMut(&mut Context) -> Poll<T> + Send + 't, 
[src]

Create a new Task from a function returning Poll<T>. If the function is already boxed, then it would be more efficient to use Task::from.

pub fn from_future<F>(f: F) -> Self where
    F: Future<Output = T> + Send + 't, 
[src]

Create a new Task from a Future<T>. If the future is already boxed, then it would be more efficient to use Task::from.

pub fn from_value(result: T) -> Self where
    T: Send + 't, 
[src]

Create a new Task from a result value.

pub fn map<'m, F, R>(self, f: F) -> Task<'m, R>

Important traits for Task<'t, T>

impl<'t, T> Future for Task<'t, T> type Output = T;
where
    F: Fn(T) -> R + Send + 'm,
    T: 'm,
    't: 'm, 
[src]

Map the result of the Task using a transformation function.

pub fn wait(self) -> T[src]

Resolve the Task to its result, parking the current thread until the result is available.

pub fn wait_deadline(self, expire: Instant) -> Result<T, Self>[src]

Resolve the Task to its result, parking the current thread until the result is available or the deadline is reached. If a timeout occurs then the Err result will contain the original Task.

pub fn wait_timeout(self, timeout: Duration) -> Result<T, Self>[src]

Resolve the Task to its result, parking the current thread until the result is available or the timeout expires. If a timeout does occur then the Err result will contain the original Task.

impl<'t, T, E> Task<'t, Result<T, E>>[src]

pub fn map_ok<'m, F, R>(self, f: F) -> Task<'m, Result<R, E>>

Important traits for Task<'t, T>

impl<'t, T> Future for Task<'t, T> type Output = T;
where
    F: Fn(T) -> R + Send + 'm,
    T: 'm,
    E: 'm,
    't: 'm, 
[src]

A helper method to map the Ok(T) result of the Task<Result<T, E>> using a transformation function.

pub fn map_err<'m, F, R>(self, f: F) -> Task<'m, Result<T, R>>

Important traits for Task<'t, T>

impl<'t, T> Future for Task<'t, T> type Output = T;
where
    F: Fn(E) -> R + Send + 'm,
    T: 'm,
    E: 'm,
    't: 'm, 
[src]

A helper method to map the Err(E) result of the Task<Result<T, E>> using a transformation function.

Trait Implementations

impl<T, '_> Debug for Task<'_, T>[src]

impl<T, '_> Eq for Task<'_, T>[src]

impl<'t, T> From<Box<dyn FnMut(&mut Context) + 't + Send>> for Task<'t, T>[src]

impl<'t, T> From<Pin<Box<dyn Future<Output = T> + 't + Send>>> for Task<'t, T>[src]

impl<'t, T: Send + 't> From<Receiver<T>> for Task<'t, Result<T, RecvError>>[src]

impl<'t, T> Future for Task<'t, T>[src]

type Output = T

The type of value produced on completion.

impl<T, '_> PartialEq<Task<'_, T>> for Task<'_, T>[src]

Auto Trait Implementations

impl<'t, T> !RefUnwindSafe for Task<'t, T>

impl<'t, T> Send for Task<'t, T>

impl<'t, T> !Sync for Task<'t, T>

impl<'t, T> Unpin for Task<'t, T>

impl<'t, T> !UnwindSafe for Task<'t, T>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<F, T, E> TryFuture for F where
    F: Future<Output = Result<T, E>> + ?Sized
[src]

type Ok = T

The type of successful values yielded by this future

type Error = E

The type of failures yielded by this future

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.