pub struct Registry { /* private fields */ }Expand description
The registry: one directory, one file per task.
Implementations§
Source§impl Registry
impl Registry
Sourcepub fn new(state_dir: impl AsRef<Path>) -> Registry
pub fn new(state_dir: impl AsRef<Path>) -> Registry
state_dir is the state directory itself (~/.eclipse/state), not the tasks/ inside it:
the caller already knows where its state lives, and this module owns the subdirectory name.
Sourcepub fn none() -> Registry
pub fn none() -> Registry
A registry that has never written anything, for a surface that must not care where the
state directory is (/tasks before the first /bg).
pub fn dir(&self) -> &Path
Sourcepub fn log_path(&self, id: &str) -> PathBuf
pub fn log_path(&self, id: &str) -> PathBuf
<id>.log: what the child printed. Kept beside the entry because a failure that only ever
existed on a terminal that is gone is a failure nobody can read.
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Whether anything has ever been registered. /tasks says one line and stops when not.
Sourcepub fn write(&self, task: &Task) -> Result<()>
pub fn write(&self, task: &Task) -> Result<()>
Write an entry. Atomic (a sibling .tmp then a rename), because /tasks may be reading
while a child is writing and half a JSON document is not a state.
Sourcepub fn list(&self) -> Vec<Task>
pub fn list(&self) -> Vec<Task>
Every entry, newest activity first. A file that does not parse is skipped rather than
reported: it is a half-written temp file at worst, and /tasks is not a JSON validator.
Sourcepub fn touch(&self, id: &str, last: &str) -> Result<()>
pub fn touch(&self, id: &str, last: &str) -> Result<()>
What the last turn did, for the row. A no-op when nothing changed, so a long run does not rewrite the same line for every event it emits.
Trait Implementations§
impl Eq for Registry
impl StructuralPartialEq for Registry
Auto Trait Implementations§
impl Forget for Registry
impl Freeze for Registry
impl Move for Registry
impl RefUnwindSafe for Registry
impl Send for Registrywhere
RawVecInner: Send,
impl Sync for Registrywhere
RawVecInner: Sync,
impl Unpin for Registry
impl UnsafeUnpin for Registry
impl UnwindSafe for Registrywhere
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,
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.