#future #timeout #promise #rust

settimeout

Creates a std::future::Future implementation to be ready at some point

3 releases

0.1.2 Mar 2, 2020
0.1.1 Mar 2, 2020
0.1.0 Mar 2, 2020

#1213 in Asynchronous

Download history 29/week @ 2023-12-17 10/week @ 2023-12-24 2/week @ 2023-12-31 26/week @ 2024-01-07 25/week @ 2024-01-14 42/week @ 2024-01-21 7/week @ 2024-01-28 12/week @ 2024-02-04 22/week @ 2024-02-11 51/week @ 2024-02-18 48/week @ 2024-02-25 69/week @ 2024-03-03 108/week @ 2024-03-10 38/week @ 2024-03-17 62/week @ 2024-03-24 69/week @ 2024-03-31

288 downloads per month
Used in ontimeexecuter

MIT license

7KB
80 lines

Crate API Minimum rustc version

settimeout-rs

Provides an implementation of std::future::Future trait to be ready at some point. Sometimes, it is needed a std::future::Future trait instance for testing purpose in any async function.

Usage

Add this to your Cargo.toml:

[dependencies]
settimeout = "0.1.2"

Examples

Create a simple std::future::Future implementation:

use futures::executor::block_on;
use std::time::Duration;
use settimeout::set_timeout;

async fn foo() {
  println!("The Future will be ready after some time");
  set_timeout(Duration::from_secs(5)).await;
  println!("Now, it is ready");
}

fn main() {
   block_on(foo());
}

Contributing

Your PRs and stars are always welcome.

No runtime deps