async_shared_timeout/runtime/
mod.rs1use core::{
3 pin::Pin,
4 task::{Context, Poll},
5 time::Duration,
6};
7
8#[cfg(feature = "tokio")]
9mod tokio;
10#[cfg(feature = "tokio")]
11pub use self::tokio::Runtime as Tokio;
12
13#[cfg(feature = "async-io")]
14mod async_io;
15#[cfg(feature = "async-io")]
16pub use self::async_io::Runtime as AsyncIo;
17
18pub trait Sleep {
20 fn reset(self: Pin<&mut Self>, timeout: Duration);
22 fn poll_sleep(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<()>;
24}
25
26pub trait Runtime {
28 type Sleep: Sleep;
30 type Instant: Instant;
32 fn create_sleep(&self, timeout: Duration) -> Self::Sleep;
34 fn now(&self) -> Self::Instant;
36}
37
38pub trait Instant {
40 fn duration_since(&self, earlier: &Self) -> Duration;
42}