[−][src]Crate kyansel
This library adds a combinator for futures, enabling a future to be cancelled when another one has completed succesfully.
Support for futures 0.1 can be enabled with the futures_01
feature
Example
use kyansel::cancellable; let (tx, rx) = oneshot::channel::<()>(); //simulate a long future let future = delay(tokio::clock::now() + std::time::Duration::from_secs(1)); //make it cancellable let cancellable = cancellable(future, rx); //create the future that will trigger the cancellation let canceller = ready(tx.send(())); //run them at the same time (example) let pair = join(cancellable, canceller); //we `.await` the join, dropping the result of the canceller since we don't care let (cancellable_result, _) = pair.await; //the return is of type CancelledResult<(), Result<(), RecvError>> let cancellable_result = cancellable_result.cancelled().unwrap().unwrap(); assert_eq!((), cancellable_result);
Modules
futures_01 | Cancellable future for futures 0.1 |
Structs
Cancellable | Future for the |
Enums
CancellableResult | Result returned by |
Traits
FutureCancellable | An extension trait for |
Functions
cancellable | Creates a new |