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
use std::{pin::Pin};
use tokio::time::{Sleep, Instant};
impl crate::Delay for Sleep {
type Value = ();
type Instant = Instant;
fn delay(duration: std::time::Duration) -> Self {
tokio::time::sleep(duration)
}
fn delay_until(deadline: Instant) -> Self {
tokio::time::sleep_until(deadline)
}
fn deadline(&self) -> Option<Instant> {
Some(self.deadline())
}
fn poll_elapsed(self: Pin<&mut Self>, cx: &mut std::task::Context<'_>) -> std::task::Poll<Self::Value> {
std::future::Future::poll(self, cx)
}
fn reset(self: Pin<&mut Self>, deadline: Instant) {
tokio::time::Sleep::reset(self, deadline)
}
}