async_sleep/
lib.rs

1#![cfg_attr(not(feature = "std"), no_std)]
2
3extern crate alloc;
4
5//
6use core::time::Duration;
7
8#[cfg(feature = "futures-util")]
9pub type SleepbleWaitBoxFuture = futures_util::future::BoxFuture<'static, ()>;
10#[cfg(not(feature = "futures-util"))]
11pub type SleepbleWaitBoxFuture =
12    core::pin::Pin<alloc::boxed::Box<dyn core::future::Future<Output = ()> + Send + 'static>>;
13
14pub trait Sleepble {
15    fn sleep(dur: Duration) -> Self;
16
17    fn wait(self) -> SleepbleWaitBoxFuture;
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::AsyncTimerPlatform;
29#[cfg(feature = "impl_tokio")]
30pub mod impl_tokio;
31#[cfg(feature = "impl_tokio")]
32pub use impl_tokio::TokioTimeSleep;
33
34#[cfg(feature = "rw")]
35pub mod rw;
36#[cfg(feature = "rw")]
37pub use self::rw::{AsyncReadWithTimeoutExt, AsyncWriteWithTimeoutExt};
38
39pub mod sleep;
40pub use sleep::sleep;
41#[cfg(feature = "std")]
42pub use sleep::sleep_until;
43
44#[cfg(feature = "timeout")]
45pub mod timeout;
46#[cfg(feature = "timeout")]
47pub use self::timeout::timeout;
48#[cfg(all(feature = "timeout", feature = "std"))]
49pub use self::timeout::timeout_at;