vault_tasks_time_management/
flow_time.rsuse std::time::Duration;
use color_eyre::{eyre::bail, Result};
use crate::{time_management_technique::TimeManagementTechnique, State};
#[derive(Debug)]
pub struct FlowTime {
break_factor: u32,
}
impl FlowTime {
pub fn new(break_factor: u32) -> Result<Self> {
if break_factor == 0 {
bail!("Break Factor for FlowTime is negative")
}
Ok(Self { break_factor })
}
}
impl TimeManagementTechnique for FlowTime {
fn switch(&mut self, state: &Option<State>, time_spent: Duration) -> State {
match state {
Some(State::Focus(_)) => State::Break(Some(time_spent / self.break_factor)),
Some(State::Break(_)) | None => State::Focus(None),
}
}
}