pub struct Store { /* private fields */ }Expand description
The task store of one project directory.
Implementations§
Source§impl Store
impl Store
pub fn dir(&self) -> &Path
Sourcepub fn load(&self) -> Result<Board, TaskError>
pub fn load(&self) -> Result<Board, TaskError>
The board as written (an empty one before the first write).
Sourcepub fn read(
&self,
now: DateTime<Utc>,
) -> Result<(Board, Vec<Change>), TaskError>
pub fn read( &self, now: DateTime<Utc>, ) -> Result<(Board, Vec<Change>), TaskError>
The board as of now: claims that ran out are given back first
(a write), and their changes returned for the caller’s notices.
Sourcepub fn write<T>(
&self,
now: DateTime<Utc>,
change: impl FnOnce(&mut Board) -> Result<T, TaskError>,
) -> Result<(T, Vec<Change>), TaskError>
pub fn write<T>( &self, now: DateTime<Utc>, change: impl FnOnce(&mut Board) -> Result<T, TaskError>, ) -> Result<(T, Vec<Change>), TaskError>
Change the board under both locks. Claims that ran out by now are
given back before change runs. Returns what change returned and
every change recorded in this write (expiries first), for notices.
Sourcepub fn read_announced(
&self,
now: DateTime<Utc>,
post: impl FnOnce(&[Change]) -> bool,
) -> Result<(Board, Vec<Change>), TaskError>
pub fn read_announced( &self, now: DateTime<Utc>, post: impl FnOnce(&[Change]) -> bool, ) -> Result<(Board, Vec<Change>), TaskError>
Store::read, then announce every transition the bus has not
taken yet (see Store::write_announced).
Sourcepub fn write_announced<T>(
&self,
now: DateTime<Utc>,
change: impl FnOnce(&mut Board) -> Result<T, TaskError>,
post: impl FnOnce(&[Change]) -> bool,
) -> Result<(T, Vec<Change>), TaskError>
pub fn write_announced<T>( &self, now: DateTime<Utc>, change: impl FnOnce(&mut Board) -> Result<T, TaskError>, post: impl FnOnce(&[Change]) -> bool, ) -> Result<(T, Vec<Change>), TaskError>
Store::write, then post the transitions the bus has not taken
yet: this write’s and any an earlier failed post left behind (from
the journal). post runs after both locks are released, so a slow
or contended bus never holds up the next task writer. It returns
whether the bus took the notices; only then does the cursor
(notices.json) move past them, so a failed bus write is retried on
the next access instead of being lost (Hive task #39). Notices are
keyed by their journal sequence, so a re-post is idempotent.
Sourcepub fn journal(&self) -> Vec<Transition>
pub fn journal(&self) -> Vec<Transition>
The journal, oldest first (a line that does not parse is skipped).