pub struct Keeper { /* private fields */ }Expand description
Holds at most one session plus at most one trigger hold. Every method that may change state returns whether it did, so the caller knows when to update the assertion and UI.
Turning off while triggers hold pauses each of them until it stops applying, so “off” always means off.
Implementations§
Source§impl Keeper
impl Keeper
pub fn session(&self) -> Option<&Session>
pub fn rule(&self) -> Option<&RuleHold>
Sourcepub fn battery_low(&self) -> Option<u8>
pub fn battery_low(&self) -> Option<u8>
The battery level Marathon turned off at, while it stays below the line.
Sourcepub fn wanted(&self) -> Option<Mode>
pub fn wanted(&self) -> Option<Mode>
The mode to hold an assertion for, if any. The screen stays on if either the session or the trigger asks for it.
Sourcepub fn apply(&mut self, verdict: Verdict, mode: Mode) -> bool
pub fn apply(&mut self, verdict: Verdict, mode: Mode) -> bool
Applies the triggers’ latest verdict, holding in mode. The first
low-battery verdict ends everything; later ones change nothing, so
the user can still turn on by hand.
Sourcepub fn start(&mut self, session: Session, now: Timestamp) -> bool
pub fn start(&mut self, session: Session, now: Timestamp) -> bool
Starts or replaces the session. A session already expired at now
is ignored and leaves the current one running.
Sourcepub fn stop(&mut self) -> bool
pub fn stop(&mut self) -> bool
The user turned off: ends the session and pauses any trigger hold.
Sourcepub fn end_session(&mut self) -> bool
pub fn end_session(&mut self) -> bool
Ends the session only, leaving triggers alone.