#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

#1151 in Asynchronous

Download history 40/week @ 2024-07-21 24/week @ 2024-07-28 26/week @ 2024-08-04 43/week @ 2024-08-11 38/week @ 2024-08-18 44/week @ 2024-08-25 86/week @ 2024-09-01 61/week @ 2024-09-08 22/week @ 2024-09-15 60/week @ 2024-09-22 63/week @ 2024-09-29 21/week @ 2024-10-06 17/week @ 2024-10-13 13/week @ 2024-10-20 18/week @ 2024-10-27 19/week @ 2024-11-03

71 downloads per month
Used in 2 crates

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