pub struct HealthState {
pub taken: BTreeMap<String, i64>,
pub reminded: BTreeMap<String, i64>,
pub unshown: BTreeMap<String, i64>,
pub not_taken: BTreeMap<String, i64>,
pub moved: BTreeMap<String, [i64; 2]>,
pub errands: BTreeMap<String, String>,
pub chat_day: Option<Date>,
pub chat_minutes: u32,
pub chats_locked_until: Option<i64>,
}Expand description
What is marked of the doses and done of the errands, kept apart from the
health file: $XDG_STATE_HOME/sioul/health-state.toml.
Fields§
§taken: BTreeMap<String, i64>Doses marked taken, by key, when (Unix seconds); kept a week.
reminded: BTreeMap<String, i64>Doses already reminded, by key; kept a week.
unshown: BTreeMap<String, i64>Doses whose reminder could not be shown while Sioul ran (a desktop
without a notification server), by key, when it was tried; kept a
week. Not a reminder: such a dose is still asked about afterwards,
under its own heading, since Sioul ran (unanswered). Written only
when there is one: an older Sioul’s file stays as it was.
not_taken: BTreeMap<String, i64>Doses answered “not taken” when asked afterwards, by key; kept a week.
moved: BTreeMap<String, [i64; 2]>Doses whose take moved the next ones, by key: where they started
before and after (Health::taken_at); kept with the mark.
errands: BTreeMap<String, String>Errands whose task was made, by key.
chat_day: Option<Date>Chats: the day counted, the minutes used that day, and covered until when.
chat_minutes: u32§chats_locked_until: Option<i64>Implementations§
Source§impl HealthState
impl HealthState
pub fn default_path() -> PathBuf
Sourcepub fn read(path: &Path) -> Result<HealthState, Unsound>
pub fn read(path: &Path) -> Result<HealthState, Unsound>
The doses’ record as written, or why it cannot be trusted. Never an
empty record in place of one that does not read: a dose taken would
look not taken, and written back empty, the sharing would take every
mark out on your other devices too. Of no bytes at all, or gone,
though written before (witnessed): lost (a crash after a write that
had not reached the disk, a full disk, a state folder wiped).
Sourcepub fn update<T>(
path: &Path,
now: i64,
change: impl FnOnce(&mut HealthState) -> T,
) -> Result<T, Problem>
pub fn update<T>( path: &Path, now: i64, change: impl FnOnce(&mut HealthState) -> T, ) -> Result<T, Problem>
The record changed by change, one writer at a time (the window, the
sharing: filelock): read again, changed, written, under the lock, so
that no change made meanwhile is written over.
Sourcepub fn set_aside(path: &Path, now: i64) -> Result<Option<PathBuf>, String>
pub fn set_aside(path: &Path, now: i64) -> Result<Option<PathBuf>, String>
A record that cannot be trusted, kept aside as <name>.unreadable-<time>
for whoever wants to look, with its witness: a new one can start. Only
once nothing it held can be taken out elsewhere (share::rebuild).
Sourcepub fn save(&mut self, path: &Path, now: i64) -> Result<(), String>
pub fn save(&mut self, path: &Path, now: i64) -> Result<(), String>
Saved, its marks older than a week dropped. Use update: it holds the lock.
Sourcepub fn to_remind(&self, health: &Health, now: &Zoned, minutes: i64) -> Vec<Dose>
pub fn to_remind(&self, health: &Health, now: &Zoned, minutes: i64) -> Vec<Dose>
The doses to remind now: due in the last minutes, not taken, not reminded yet.
Sourcepub fn unanswered(
&self,
health: &Health,
now: &Zoned,
hours: i64,
grace: i64,
) -> Vec<Dose>
pub fn unanswered( &self, health: &Health, now: &Zoned, hours: i64, grace: i64, ) -> Vec<Dose>
The doses of the last hours, past their time by grace minutes,
neither marked nor reminded: due while Sioul ran nowhere, or while it
ran but could not show their reminder (unshown, reminder_unshown).
Asked about afterwards, as a question on the past; never reminded to
take now.
Sourcepub fn reminder_unshown(&self, key: &str) -> bool
pub fn reminder_unshown(&self, key: &str) -> bool
Whether Sioul ran when key fell due but could not show its reminder
(no notification server), here or on another device that shares its
doses: its question then says so, never “while Sioul was closed”.
Sourcepub fn due_today(
&self,
health: &Health,
now: &Zoned,
hours: i64,
grace: i64,
) -> Vec<Dose>
pub fn due_today( &self, health: &Health, now: &Zoned, hours: i64, grace: i64, ) -> Vec<Dose>
Today’s doses from their time on, not marked yet (taken, or said not
taken), for the Porch: reminded or not, since a reminder can go unseen;
until marked, until the day ends, or hours after their time (as far
back as a dose is asked about). Those due while Sioul ran nowhere
(unanswered) are asked about apart, and left out here.
Sourcepub fn chat_minute(&mut self, limit: &ChatLimit, now: &Zoned) -> bool
pub fn chat_minute(&mut self, limit: &ChatLimit, now: &Zoned) -> bool
One more minute of chats today; covered once the day’s limit is reached. Returns whether chats are covered now.
Sourcepub fn chats_covered(&self, now: &Zoned) -> bool
pub fn chats_covered(&self, now: &Zoned) -> bool
Whether chats are covered now.
Trait Implementations§
Source§impl Clone for HealthState
impl Clone for HealthState
Source§fn clone(&self) -> HealthState
fn clone(&self) -> HealthState
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for HealthState
impl Debug for HealthState
Source§impl Default for HealthState
impl Default for HealthState
Source§fn default() -> HealthState
fn default() -> HealthState
Source§impl<'de> Deserialize<'de> for HealthState
impl<'de> Deserialize<'de> for HealthState
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>,
Source§impl PartialEq for HealthState
impl PartialEq for HealthState
Source§impl Serialize for HealthState
impl Serialize for HealthState
impl StructuralPartialEq for HealthState
Auto Trait Implementations§
impl Freeze for HealthState
impl RefUnwindSafe for HealthState
impl Send for HealthState
impl Sync for HealthState
impl Unpin for HealthState
impl UnsafeUnpin for HealthState
impl UnwindSafe for HealthState
Blanket Implementations§
§impl<T> AnyEq for T
impl<T> AnyEq for T
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Conv for T
impl<T> Conv for T
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.