userd 0.2.0

A user daemon, managing services and regular running of jobs, in user space.
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()
    }
}