pub struct State {Show 14 fields
pub session: String,
pub prompt: String,
pub interval: String,
pub times: Option<u32>,
pub until: Option<String>,
pub status: Status,
pub ended: Option<Ended>,
pub fired: u32,
pub skipped: u32,
pub next_due_ms: i64,
pub created_ms: i64,
pub owner: Owner,
pub owner_pid: u32,
pub note: Option<String>,
}Expand description
One session’s loop, as it is written to disk.
Fields§
§session: String§prompt: String§interval: StringSchedule::describe()’s own words — the same text /loop status prints, re-parsed on
load, so the file cannot hold a schedule the parser would refuse.
times: Option<u32>§until: Option<String>§status: Status§ended: Option<Ended>§fired: u32Ticks that actually ran.
skipped: u32Ticks that landed while a run was in flight. Recorded, never queued: a backlog of ticks arriving at once is a busy loop with a schedule’s name on it.
next_due_ms: i64When this tick’s successor is due, in epoch ms. Zero when the loop has not started or has ended.
created_ms: i64§owner: Owner§owner_pid: u32§note: Option<String>The last thing worth saying about this loop: a skipped tick, a refused --until answer.
Implementations§
Source§impl State
impl State
Sourcepub fn start(session: &str, spec: Spec, owner: Owner, now_ms: i64) -> State
pub fn start(session: &str, spec: Spec, owner: Owner, now_ms: i64) -> State
A fresh loop, due one interval from now — not immediately, because starting something and firing it in the same second is not what “every 2m” means.
Sourcepub fn schedule(&self) -> Result<Schedule>
pub fn schedule(&self) -> Result<Schedule>
The schedule this record names, or the parse error that says the file was edited badly.
pub fn spec(&self) -> Result<Spec>
Sourcepub fn record(&mut self, now_ms: i64, outcome: Outcome)
pub fn record(&mut self, now_ms: i64, outcome: Outcome)
Record what happened to the tick that was due, and arm the next one.
The next moment is counted from this tick rather than from the one before it, so a tick that ran for two intervals does not fire twice in a row to catch up. A skipped tick is armed the same way: a busy session loses that tick and the schedule keeps its shape.
pub fn end(&mut self, why: Ended)
pub fn pause(&mut self)
Sourcepub fn resume(&mut self, now_ms: i64)
pub fn resume(&mut self, now_ms: i64)
Resume, due one interval from now: a loop paused for an hour does not owe an hour of ticks.
Sourcepub fn owner_alive(&self) -> bool
pub fn owner_alive(&self) -> bool
Whether the process that owns this loop is still the one running it.
This is the honest answer to “is my loop still going” after a CLI exited: the record is
still on disk, and it is still Running, but nobody is driving it. Unix asks the kernel;
elsewhere the answer is assumed to be yes rather than invented from nothing.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for State
impl<'de> Deserialize<'de> for State
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for State
impl StructuralPartialEq for State
Auto Trait Implementations§
impl Forget for State
impl Freeze for State
impl Move for State
impl RefUnwindSafe for State
impl Send for Statewhere
RawVecInner: Send,
impl Sync for Statewhere
RawVecInner: Sync,
impl Unpin for State
impl UnsafeUnpin for State
impl UnwindSafe for Statewhere
RawVecInner: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.