2 releases

0.6.2 Nov 20, 2024
0.6.1 Nov 20, 2024

#810 in Asynchronous

Download history 594/week @ 2024-11-20 128/week @ 2024-11-27 164/week @ 2024-12-04 219/week @ 2024-12-11 273/week @ 2024-12-18 111/week @ 2024-12-25 59/week @ 2025-01-01 98/week @ 2025-01-08 49/week @ 2025-01-15 73/week @ 2025-01-22 68/week @ 2025-01-29 188/week @ 2025-02-05 114/week @ 2025-02-12 195/week @ 2025-02-19 56/week @ 2025-02-26 145/week @ 2025-03-05

536 downloads per month
Used in 3 crates

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