pub struct Journal { /* private fields */ }Expand description
The journal of a host: the mutating commands that succeeded, in order, with scrubbed params
(replay, session logs, agent “what happened”). Also tracks the current nesting depth of
crate::Registry::execute.
A capped ring: past cap entries the oldest drop are removed in one go. By default only
top-level calls (depth 0) are recorded; Journal::record_nested records nested calls too.
Implementations§
Source§impl Journal
impl Journal
pub fn new() -> Self
Sourcepub fn with_cap(cap: usize, drop: usize) -> Self
pub fn with_cap(cap: usize, drop: usize) -> Self
Keep at most cap entries (at least 1), dropping the oldest drop (1..=cap) when full.
Sourcepub fn record_nested(self, yes: bool) -> Self
pub fn record_nested(self, yes: bool) -> Self
Also record commands run from inside other commands.
Sourcepub fn set_observer(&mut self, observer: Option<RunObserver>)
pub fn set_observer(&mut self, observer: Option<RunObserver>)
Tell observer about every top-level command that runs from now on (None: nobody).
Telemetry uses this; crate::Registry::execute calls it after crate::Host::after.
pub fn observer(&self) -> Option<&RunObserver>
Sourcepub fn depth(&self) -> usize
pub fn depth(&self) -> usize
Current nesting depth: 0 outside any command, 1 inside a top-level command…
Sourcepub fn set_depth(&mut self, depth: usize)
pub fn set_depth(&mut self, depth: usize)
Set the nesting depth. crate::Registry::execute does this around every command; a host
sets it only to run a command from one of its hooks as nested (see crate::Host), and
puts the old value back afterwards.
Sourcepub fn push(&mut self, id: impl Into<String>, params: Value)
pub fn push(&mut self, id: impl Into<String>, params: Value)
Record a call (the chokepoint does this; hosts may record extra entries).
pub fn entries( &self, ) -> impl DoubleEndedIterator<Item = &JournalEntry> + ExactSizeIterator
Sourcepub fn since(&self, seq: u64) -> impl Iterator<Item = &JournalEntry>
pub fn since(&self, seq: u64) -> impl Iterator<Item = &JournalEntry>
Entries recorded at or after sequence number seq.
pub fn last(&self) -> Option<&JournalEntry>
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
Sourcepub fn truncate(&mut self, len: usize)
pub fn truncate(&mut self, len: usize)
Keep only the first len entries (drop the newest; e.g. calls undone and then replaced).
Sequence numbers already handed out are not reused.
Sourcepub fn retain(&mut self, keep: impl FnMut(&JournalEntry) -> bool)
pub fn retain(&mut self, keep: impl FnMut(&JournalEntry) -> bool)
Keep only the entries keep returns true for, in order.
Sourcepub fn pop(&mut self) -> Option<JournalEntry>
pub fn pop(&mut self) -> Option<JournalEntry>
Remove and return the newest entry.