async_interval/
lib.rs

1#![cfg_attr(not(feature = "std"), no_std)]
2
3extern crate alloc;
4
5//
6use alloc::boxed::Box;
7use core::{future::Future, pin::Pin, time::Duration};
8
9pub trait Intervalable {
10    fn interval(dur: Duration) -> Self;
11
12    fn wait<'a>(&'a mut self) -> Pin<Box<dyn Future<Output = ()> + Send + 'a>>;
13
14    #[cfg(feature = "std")]
15    fn wait_for_std<'a>(
16        &'a mut self,
17    ) -> Pin<Box<dyn Future<Output = Option<std::time::Instant>> + Send + 'a>>;
18}
19
20//
21#[cfg(feature = "impl_async_io")]
22pub mod impl_async_io;
23#[cfg(feature = "impl_async_io")]
24pub use impl_async_io::AsyncIoTimer;
25#[cfg(feature = "impl_async_timer")]
26pub mod impl_async_timer;
27#[cfg(feature = "impl_async_timer")]
28pub use impl_async_timer::AsyncTimerInterval;
29#[cfg(feature = "impl_tokio")]
30pub mod impl_tokio;
31#[cfg(feature = "impl_tokio")]
32pub use impl_tokio::TokioTimeInterval;
33
34//
35#[cfg(feature = "stream")]
36pub mod stream;
37#[cfg(feature = "stream")]
38pub use stream::{
39    intervalable_iter_stream, intervalable_repeat_stream, intervalable_repeat_with_stream,
40};