https://github.com/irrustible/smol-timeout
A way to poll a future until it or a timer completes
https://github.com/irrustible/smol-timeout
async concurrency futures rust
Last synced: 5 days ago
JSON representation
A way to poll a future until it or a timer completes
- Host: GitHub
- URL: https://github.com/irrustible/smol-timeout
- Owner: irrustible
- License: mpl-2.0
- Created: 2020-06-01T23:20:16.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2025-03-04T07:58:07.000Z (about 2 months ago)
- Last Synced: 2025-04-19T10:21:11.477Z (8 days ago)
- Topics: async, concurrency, futures, rust
- Language: Rust
- Homepage:
- Size: 23.4 KB
- Stars: 4
- Watchers: 2
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# `smol-timeout`
[](https://github.com/r3v2d0g/smol-timeout/blob/main/LICENSE.txt) [](https://crates.io/crates/smol-timeout) [](https://docs.rs/smol-timeout)
A way to poll a future until it or a timer completes.
## Example
```rust
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 .