1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#![warn(missing_docs)]
#![cfg_attr(feature = "no_std", no_std)]
#![cfg_attr(feature = "cargo-clippy", allow(clippy::style))]
#[cfg(feature = "no_std")]
#[allow(unused)]
extern crate alloc;
#[cfg(not(feature = "no_std"))]
#[allow(unused)]
use std as alloc;
use core::{time, future};
#[macro_use]
mod utils;
pub mod oneshot;
mod timed;
mod interval;
pub use oneshot::Oneshot;
pub use timed::{Timed, Expired};
pub use interval::Interval;
pub fn timed<F: future::Future>(job: F, timeout: time::Duration) -> impl future::Future<Output=Result<F::Output, Expired<F, oneshot::Timer>>> {
unsafe {
Timed::platform_new_unchecked(job, timeout)
}
}
pub fn interval(interval: time::Duration) -> impl future::Future<Output=Interval<oneshot::Timer>> {
Interval::platform_new(interval)
}