#future-stream #timeout #async #target #duration #futures-timer #wasm32-unknown-unknown

futures-timeout

A utility that provides timeouts for futures and streams

4 releases

0.1.3 Jul 17, 2025
0.1.2 Mar 5, 2025
0.1.1 Jan 3, 2025
0.1.0 Apr 12, 2024

#350 in Asynchronous

Download history 156/week @ 2025-08-04 165/week @ 2025-08-11 122/week @ 2025-08-18 74/week @ 2025-08-25 171/week @ 2025-09-01 88/week @ 2025-09-08 102/week @ 2025-09-15 60/week @ 2025-09-22 144/week @ 2025-09-29 122/week @ 2025-10-06 221/week @ 2025-10-13 249/week @ 2025-10-20 213/week @ 2025-10-27 230/week @ 2025-11-03 197/week @ 2025-11-10 223/week @ 2025-11-17

893 downloads per month
Used in 3 crates

Apache-2.0 OR MIT

10KB
123 lines

futures-timeout

A simple utility that provides timeouts for futures and streams, which utilizes futures-timer. This library is compatible with wasm32-unknown-unknown target.

fn main() {
    futures::executor::block_on(async move {
        use std::time::Duration;
        use futures_timeout::TimeoutExt;
        
        let fut = async {
            futures_timer::Delay::new(Duration::from_secs(30)).await;
        };

        fut.timeout(Duration::from_secs(5))
            .await
            .expect_err("should fail");
    });
}

Dependencies

~1–1.9MB
~35K SLoC