#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

#1365 in Asynchronous

Download history 72/week @ 2024-03-04 109/week @ 2024-03-11 38/week @ 2024-03-18 59/week @ 2024-03-25 77/week @ 2024-04-01 22/week @ 2024-04-08 34/week @ 2024-04-15 39/week @ 2024-04-22 40/week @ 2024-04-29 37/week @ 2024-05-06 43/week @ 2024-05-13 37/week @ 2024-05-20 46/week @ 2024-05-27 36/week @ 2024-06-03 42/week @ 2024-06-10 31/week @ 2024-06-17

157 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