Crates.io | smoltimeout |
lib.rs | smoltimeout |
version | |
source | src |
created_at | 2024-11-20 14:31:20.480257 |
updated_at | 2024-11-20 14:35:34.079039 |
description | A way to poll a future until it or a timer completes. |
homepage | |
repository | https://github.com/delta4chat/smol-timeout |
max_upload_size | |
id | 1454830 |
Cargo.toml error: | TOML parse error at line 21, column 1 | 21 | autolib = false | ^^^^^^^ unknown field `autolib`, expected one of `name`, `version`, `edition`, `authors`, `description`, `readme`, `license`, `repository`, `homepage`, `documentation`, `build`, `resolver`, `links`, `default-run`, `default_dash_run`, `rust-version`, `rust_dash_version`, `rust_version`, `license-file`, `license_dash_file`, `license_file`, `licenseFile`, `license_capital_file`, `forced-target`, `forced_dash_target`, `autobins`, `autotests`, `autoexamples`, `autobenches`, `publish`, `metadata`, `keywords`, `categories`, `exclude`, `include` |
size | 0 |
smol-timeout
A way to poll a future until it or a timer completes.
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));
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/.