2 releases
0.1.1 | Oct 1, 2024 |
---|---|
0.1.0 | Oct 1, 2024 |
#7 in #allowing
5KB
88 lines
inspect-timeout
inspect-timeout
is a Rust library that provides a Future
combinator, allowing you to apply a timeout with a custom callback that gets executed when the timeout elapses. It's useful when you need to handle cases where a Future
doesn't complete within a specified time.
Features
- Apply a timeout to any
Future
- Execute a custom function if the timeout expires
Example
use std::time::Duration;
use inspect_timeout::InspectTimeoutExt;
#[tokio::main]
async fn main() {
tokio::time::sleep(Duration::from_secs(15))
.inspect_timeout(Duration::from_secs(5), || println!("warning"))
.await;
}
Dependencies
~2.3–8MB
~63K SLoC