quixutils 0.13.2

Common helpers and utils
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
use std::future::Future;
use std::time::{Duration, Instant};
use tokio::timer::Delay;

pub fn delay(dur: Duration) -> impl Future<Output = Result<(), tokio::timer::Error>> {
    use futures::compat::Future01CompatExt;
    Delay::new(Instant::now() + dur).compat()
}

pub fn delay_ms(ms: u64) -> impl Future<Output = Result<(), tokio::timer::Error>> {
    delay(Duration::from_millis(ms))
}