use derive_where::derive_where;
use crate::{Error, Id, Support};
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
#[derive_where(Debug, PartialEq, Eq)]
pub struct Event<B: crate::Api + ?Sized> {
pub timer: Id<crate::Timer<B>>,
}
impl<B: crate::Api> From<Event<B>> for crate::Event<B> {
fn from(event: Event<B>) -> Self {
crate::Event::Timer(event)
}
}
pub trait Api: Support<usize> + Send {
fn arm(timer: Id<Self>, command: &Command) -> Result<(), Error>;
fn disarm(timer: Id<Self>) -> Result<(), Error>;
}
#[derive(Debug, Clone)]
pub struct Command {
pub periodic: bool,
pub duration_ms: usize,
}