Skip to main content

Keeper

Struct Keeper 

Source
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

Source

pub fn session(&self) -> Option<&Session>

Source

pub fn rule(&self) -> Option<&RuleHold>

Source

pub fn paused(&self) -> Option<String>

Triggers the user turned off that still apply.

Source

pub fn battery_low(&self) -> Option<u8>

The battery level Marathon turned off at, while it stays below the line.

Source

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.

Source

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.

Source

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.

Source

pub fn stop(&mut self) -> bool

The user turned off: ends the session and pauses any trigger hold.

Source

pub fn end_session(&mut self) -> bool

Ends the session only, leaving triggers alone.

Source

pub fn snapshot(&self) -> Snapshot

Source

pub fn restore(&mut self, snap: Snapshot, now: Timestamp) -> bool

Comes back to a snapshot. A session whose deadline passed while Marathon was down ends, as it would have had Marathon kept running.

Source

pub fn tick(&mut self, now: Timestamp) -> bool

Ends the session if its deadline has passed.

Trait Implementations§

Source§

impl Clone for Keeper

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Keeper

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Keeper

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Forget for Keeper

§

impl Freeze for Keeper

§

impl Move for Keeper

§

impl RefUnwindSafe for Keeper

§

impl Send for Keeper
where RawVecInner: Send,

§

impl Sync for Keeper
where RawVecInner: Sync,

§

impl Unpin for Keeper
where *const u8 is !null: Unpin,

§

impl UnsafeUnpin for Keeper

§

impl UnwindSafe for Keeper
where RawVecInner: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.