1 unstable release

0.6.1 Aug 28, 2024

#1832 in Asynchronous

Download history 143/week @ 2024-12-27 94/week @ 2025-01-03 137/week @ 2025-01-10 169/week @ 2025-01-17 106/week @ 2025-01-24 145/week @ 2025-01-31 193/week @ 2025-02-07 109/week @ 2025-02-14 201/week @ 2025-02-21 116/week @ 2025-02-28 243/week @ 2025-03-07 202/week @ 2025-03-14 233/week @ 2025-03-21 323/week @ 2025-03-28 220/week @ 2025-04-04 161/week @ 2025-04-11

971 downloads per month
Used in 12 crates (3 directly)

MPL-2.0 license

12KB

smol-timeout

img img img

A way to poll a future until it or a timer completes.

Example

use async_io::Timer;
use smol_timeout::TimeoutExt;
use std::time::Duration;

let foo = async {
    Timer::new(Duration::from_millis(250)).await;
    24
};

let foo = foo.timeout(Duration::from_millis(100));
assert_eq!(foo.await, None);

let bar = async {
    Timer::new(Duration::from_millis(100)).await;
    42
};

let bar = bar.timeout(Duration::from_millis(250));
assert_eq!(bar.await, Some(42));

License

This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with this file, You can obtain one at http://mozilla.org/MPL/2.0/.

Dependencies

~3–12MB
~155K SLoC