🗂️ interruptible
Stops a future producer or stream from producing values when interrupted.
For a future that returns either Result<T, ()> or ControlFlow<T, ()>,
calling fut.interruptible_*(tx) causes the returned value to be Err(())
or Break(T) if an interruption signal is received while that future is
executing.
This means the future is progressed to completion, but the return value signals the producer to stop yielding futures.
For a stream, when the interrupt signal is received, the current future is run to completion, but the stream is not polled for the next item.
Usage
Add the following to Cargo.toml
= "0.2.4"
# Enables `InterruptibleStreamExt`
= { = "0.2.4", = ["stream"] }
# Enables:
#
# * `InterruptibleFutureExt::{interruptible_control_ctrl_c, interruptible_result_ctrl_c}`
# * `InterruptibleStreamExt::interruptible_ctrl_c` if the `"stream"` feature is also enabled.
= { = "0.2.4", = ["ctrl_c"] }
Examples
Future<Output = ControlFlow<B, C>>
use ControlFlow;
use FutureExt;
use ;
use ;
async
InterruptibleStreamExt with features = ["stream"]
Stops a stream from producing values when an interrupt signal is received.
See the interrupt_strategy module for different ways the stream
interruption can be handled.
async
License
Licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE or https://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or https://opensource.org/licenses/MIT)
at your option.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.