Struct futures::future::Abortable [−][src]
#[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) -> Abortable<Fut>[src]
pub fn new(future: Fut, reg: AbortRegistration) -> Abortable<Fut>Creates 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::prelude::*; 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> Unpin for Abortable<Fut> where
Fut: Unpin, [src]
impl<Fut> Unpin for Abortable<Fut> where
Fut: Unpin, impl<Fut> Clone for Abortable<Fut> where
Fut: Clone, [src]
impl<Fut> Clone for Abortable<Fut> where
Fut: Clone, 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> Debug for Abortable<Fut> where
Fut: Debug, [src]
impl<Fut> Debug for Abortable<Fut> where
Fut: Debug, fn fmt(&self, f: &mut Formatter) -> Result<(), Error>[src]
fn fmt(&self, f: &mut Formatter) -> Result<(), Error>Formats the value using the given formatter. Read more
impl<Fut> Future for Abortable<Fut> where
Fut: Future, [src]
impl<Fut> Future for Abortable<Fut> where
Fut: Future, type Output = Result<<Fut as Future>::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<Abortable<Fut>>,
cx: &mut Context
) -> Poll<<Abortable<Fut> as Future>::Output>[src]
fn poll(
self: PinMut<Abortable<Fut>>,
cx: &mut Context
) -> Poll<<Abortable<Fut> as Future>::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