[−][src]Struct suspend::Task
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]
F: FnMut(&mut Context) -> Poll<T> + Send + 't,
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]
F: Future<Output = T> + Send + 't,
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]
T: Send + 't,
Create a new Task
from a result value.
pub fn map<'m, F, R>(self, f: F) -> Task<'m, R>ⓘ where
F: Fn(T) -> R + Send + 'm,
T: 'm,
't: 'm,
[src]
F: Fn(T) -> R + Send + 'm,
T: 'm,
't: 'm,
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>>ⓘ where
F: Fn(T) -> R + Send + 'm,
T: 'm,
E: 'm,
't: 'm,
[src]
F: Fn(T) -> R + Send + 'm,
T: 'm,
E: 'm,
't: 'm,
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>>ⓘ where
F: Fn(E) -> R + Send + 'm,
T: 'm,
E: 'm,
't: 'm,
[src]
F: Fn(E) -> R + Send + 'm,
T: 'm,
E: 'm,
't: 'm,
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.
fn poll(self: Pin<&mut Self>, cx: &mut Context) -> Poll<Self::Output>
[src]
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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<F, T, E> TryFuture for F where
F: Future<Output = Result<T, E>> + ?Sized,
[src]
F: Future<Output = Result<T, E>> + ?Sized,
type Ok = T
The type of successful values yielded by this future
type Error = E
The type of failures yielded by this future
fn try_poll(self: Pin<&mut F>, cx: &mut Context) -> Poll<<F as Future>::Output>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,