zentime_rs_timer/pomodoro_timer/
on_end_handler.rs1use std::rc::Rc;
2
3use crate::timer::TimerEndHandler;
4
5use super::state::PomodoroTimerState;
6
7#[derive(Debug, Copy, Clone, PartialEq, Eq)]
9pub enum TimerKind {
10 Interval,
12
13 Break,
15}
16
17pub type OnTimerEnd = Rc<dyn Fn(PomodoroTimerState, Option<&str>, TimerKind)>;
18
19pub struct OnEndHandler {
21 pub on_timer_end: OnTimerEnd,
22 pub state: PomodoroTimerState,
23 pub notification: Option<&'static str>,
24 pub kind: TimerKind,
25}
26
27impl TimerEndHandler for OnEndHandler {
28 fn call(&mut self) {
29 (self.on_timer_end)(self.state, self.notification, self.kind);
30 }
31}