async_std_resolver/
time.rs1use std::future::Future;
9use std::time::Duration;
10
11use async_trait::async_trait;
12use hickory_resolver::proto::Time;
13
14#[derive(Clone, Copy)]
16pub struct AsyncStdTime;
17
18#[async_trait]
19impl Time for AsyncStdTime {
20 async fn delay_for(duration: Duration) {
21 async_std::task::sleep(duration).await
22 }
23
24 async fn timeout<F: 'static + Future + Send>(
25 duration: Duration,
26 future: F,
27 ) -> Result<F::Output, std::io::Error> {
28 async_std::future::timeout(duration, future)
29 .await
30 .map_err(move |_| std::io::Error::new(std::io::ErrorKind::TimedOut, "future timed out"))
31 }
32}