pub struct Task<T> { /* private fields */ }Expand description
An awaitable task handle. Dropping it cancels the task.
Implementations§
Source§impl<T> Task<T>
impl<T> Task<T>
Sourcepub async fn cancel(self) -> Option<T>
pub async fn cancel(self) -> Option<T>
Requests cancellation and waits for cancellation to finish.
Sourcepub fn fallible(self) -> FallibleTask<T> ⓘ
pub fn fallible(self) -> FallibleTask<T> ⓘ
Converts cancellation from a panic into None.
§Panics
Panics only if the internal task handle has already been consumed. This
cannot occur through the public API because this method consumes self.
Sourcepub fn is_finished(&self) -> bool
pub fn is_finished(&self) -> bool
Returns whether the task has finished.
Trait Implementations§
Auto Trait Implementations§
impl<T> !RefUnwindSafe for Task<T>
impl<T> !UnwindSafe for Task<T>
impl<T> Freeze for Task<T>
impl<T> Send for Task<T>
impl<T> Sync for Task<T>
impl<T> UnsafeUnpin for Task<T>where
Option<TaskInner<T>>: UnsafeUnpin,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<F> FutureExt for F
impl<F> FutureExt for F
Source§fn catch_unwind(self) -> CatchUnwind<Self> ⓘwhere
Self: Sized + UnwindSafe,
fn catch_unwind(self) -> CatchUnwind<Self> ⓘwhere
Self: Sized + UnwindSafe,
Catches panics while polling the future. Read more
Source§impl<F> IntoFuture for Fwhere
F: Future,
impl<F> IntoFuture for Fwhere
F: Future,
Source§type IntoFuture = F
type IntoFuture = F
Which kind of future are we turning this into?
Source§fn into_future(self) -> <F as IntoFuture>::IntoFuture
fn into_future(self) -> <F as IntoFuture>::IntoFuture
Creates a future from a value. Read more