use futures::FutureExt;
use std::time::Duration;
use crate::prelude::*;
pub(crate) struct Every {
duration: Duration,
}
impl Every {
pub(crate) fn new(duration: Duration) -> Self {
Self { duration }
}
}
impl super::Trigger for Every {
fn wait_for(&self) -> futures::future::BoxFuture<'static, Result<()>> {
let duration = self.duration;
async move {
tokio::time::sleep(duration).await;
Ok(())
}
.boxed()
}
}