[−][src]Module kyansel::futures_01
Cancellable future for futures 0.1
Example
use kyansel::futures_01::{CancellableError, FutureCancellable}; let (tx, rx) = oneshot::channel::<()>(); let deadline = tokio::clock::now() + std::time::Duration::from_secs(1).into(); //simulate a long-running future let cancellable = Delay::new(deadline) .map_err(|_| ()) .and_then(|_| Ok(())) //add a way to cancel it .cancel_with(rx) .map_err(|e| { assert_eq!(e, CancellableError::Cancelled(())); }) .map_err(|_| ()); let canceller = tx.send(()).into_future(); run( //join it with the canceller cancellable.join(canceller) //it will cancel immediately returning err .and_then(|(_ok, _tx_send)| Ok(println!("unreachable"))), );
Structs
Cancellable | Future for the |
Enums
CancellableError | Error returned by |
Traits
FutureCancellable | An extension trait for |
Functions
cancellable | Creates a new |