Skip to main content

Crate marathon_core

Crate marathon_core 

Source
Expand description

Platform-independent logic for Marathon: what a keep-awake session is, when it ends, how durations are written, and the IPC protocol.

Nothing here touches macOS, so it all tests on any platform.

Modules§

ai
AI-aware mode: keep the Mac awake while AI agents and local models are working, and let it sleep again once they go quiet.
protocol
The local IPC protocol: one JSON request line, one JSON reply line.
rules
Triggers and schedules: when to keep the Mac awake without being asked, and when to stop to save the battery. Pure logic over a snapshot of the world, so every rule tests without a Mac.

Structs§

Keeper
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.
ParseError
RuleHold
Triggers currently keeping the Mac awake.
Session
One keep-awake request: from when, until when, and who asked.
Snapshot
What Marathon must remember to come back exactly as it was after a crash or restart. Trigger holds are not kept: they are worked out again from the world.
TimeZone
A representation of a time zone.
Timestamp
An instant in time represented as the number of nanoseconds since the Unix epoch.

Enums§

Mode
What to keep awake.
Until
When a session should end, as the user wrote it.

Functions§

format_clock
A deadline as a local 24-hour clock time, e.g. 17:30.
format_remaining
Short human form of what is left: 2h 05m, 14m, 45s. Minutes round up, like the menu bar countdown, so on 2m reads “2m”.
format_time
A time of day on the 24-hour clock, e.g. 09:00.