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
#![cfg_attr(not(feature = "std"), no_std)]

extern crate alloc;

//
use core::time::Duration;

#[cfg(feature = "futures-util")]
pub type SleepbleWaitBoxFuture = futures_util::future::BoxFuture<'static, ()>;
#[cfg(not(feature = "futures-util"))]
pub type SleepbleWaitBoxFuture =
    core::pin::Pin<alloc::boxed::Box<dyn core::future::Future<Output = ()> + Send + 'static>>;

pub trait Sleepble {
    fn sleep(dur: Duration) -> Self;

    fn wait(self) -> SleepbleWaitBoxFuture;
}

//
#[cfg(feature = "impl_async_io")]
pub mod impl_async_io;
#[cfg(feature = "impl_async_io")]
pub use impl_async_io::AsyncIoTimer;
#[cfg(feature = "impl_async_timer")]
pub mod impl_async_timer;
#[cfg(feature = "impl_async_timer")]
pub use impl_async_timer::AsyncTimerPlatform;
#[cfg(feature = "impl_tokio")]
pub mod impl_tokio;
#[cfg(feature = "impl_tokio")]
pub use impl_tokio::TokioTimeSleep;

#[cfg(feature = "rw")]
pub mod rw;
#[cfg(feature = "rw")]
pub use self::rw::{AsyncReadWithTimeoutExt, AsyncWriteWithTimeoutExt};

pub mod sleep;
pub use sleep::sleep;
#[cfg(feature = "std")]
pub use sleep::sleep_until;

#[cfg(feature = "timeout")]
pub mod timeout;
#[cfg(feature = "timeout")]
pub use self::timeout::timeout;
#[cfg(all(feature = "timeout", feature = "std"))]
pub use self::timeout::timeout_at;