use ambassador::delegatable_trait;
use std::time::Duration;
#[delegatable_trait]
pub trait ClockAlg {
type Moment;
fn now(&self) -> Self::Moment;
fn since(&self, moment: &Self::Moment) -> Duration;
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub struct Attending<Id, Run, Moment> {
pub id: Id,
pub run: Run,
pub began: Moment,
pub held_since: Option<Moment>,
pub held_for: Duration,
}
impl<Id, Run, Moment> Attending<Id, Run, Moment> {
pub const fn begun(id: Id, run: Run, began: Moment) -> Self {
Self { id, run, began, held_since: None, held_for: Duration::ZERO }
}
}