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
50
51
#![warn(missing_docs)]
#![no_std]
#![cfg_attr(feature = "cargo-clippy", allow(clippy::style))]
#[allow(unused_imports)]
extern crate alloc;
#[cfg(feature = "std")]
extern crate std;
use core::{time, future};
#[macro_use]
mod utils;
pub mod state;
pub mod timer;
mod timed;
mod interval;
pub use state::Callback;
pub use timer::{SyncTimer, Timer, new_sync_timer, new_timer};
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, timer::Platform>>> {
unsafe {
Timed::platform_new_unchecked(job, timeout)
}
}
pub fn interval(interval: time::Duration) -> Interval<timer::Platform> {
Interval::platform_new(interval)
}