[−][src]Struct futures_util::future::Abortable
#[must_use = "futures do nothing unless polled"]pub struct Abortable<Fut> { /* fields omitted */ }
A future which can be remotely short-circuited using an AbortHandle.
Methods
impl<Fut> Abortable<Fut> where
Fut: Future, [src]
impl<Fut> Abortable<Fut> where
Fut: Future, pub fn new(future: Fut, reg: AbortRegistration) -> Self[src]
pub fn new(future: Fut, reg: AbortRegistration) -> SelfCreates a new Abortable future using an existing AbortRegistration.
AbortRegistrations can be acquired through AbortHandle::new.
When abort is called on the handle tied to reg or if abort has
already been called, the future will complete immediately without making
any further progress.
Example:
use futures::future::{ready, Abortable, AbortHandle, Aborted}; use futures::executor::block_on; let (abort_handle, abort_registration) = AbortHandle::new_pair(); let future = Abortable::new(ready(2), abort_registration); abort_handle.abort(); assert_eq!(block_on(future), Err(Aborted));
Trait Implementations
impl<Fut: Debug> Debug for Abortable<Fut>[src]
impl<Fut: Debug> Debug for Abortable<Fut>fn fmt(&self, f: &mut Formatter) -> Result[src]
fn fmt(&self, f: &mut Formatter) -> ResultFormats the value using the given formatter. Read more
impl<Fut: Clone> Clone for Abortable<Fut>[src]
impl<Fut: Clone> Clone for Abortable<Fut>fn clone(&self) -> Abortable<Fut>[src]
fn clone(&self) -> Abortable<Fut>Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)1.0.0[src]
fn clone_from(&mut self, source: &Self)1.0.0
[src]Performs copy-assignment from source. Read more
impl<Fut: Unpin> Unpin for Abortable<Fut>[src]
impl<Fut: Unpin> Unpin for Abortable<Fut>impl<Fut> Future for Abortable<Fut> where
Fut: Future, [src]
impl<Fut> Future for Abortable<Fut> where
Fut: Future, type Output = Result<Fut::Output, Aborted>
🔬 This is a nightly-only experimental API. (futures_api)
futures in libcore are unstable
The result of the Future.
fn poll(self: PinMut<Self>, cx: &mut Context) -> Poll<Self::Output>[src]
fn poll(self: PinMut<Self>, cx: &mut Context) -> Poll<Self::Output>🔬 This is a nightly-only experimental API. (futures_api)
futures in libcore are unstable
Attempt to resolve the future to a final value, registering the current task for wakeup if the value is not yet available. Read more