pub struct Store<'a> { /* private fields */ }Expand description
Current records for one terminal with a fixed capacity.
Use Store::from_slots to supply storage without an allocator.
With the alloc feature, Store::new(capacity) owns heap storage instead.
Updates replace every explicit field. Lookup does not affect eviction order.
Change callbacks borrow records only for the duration of the call.
Records belong to the terminal, so screen switches require no store action.
Implementations§
Source§impl Store<'_>
impl Store<'_>
Sourcepub fn apply_with_changes(
&mut self,
report: Report<'_>,
on_change: impl FnMut(Change<'_>),
) -> Result<(), Error>
pub fn apply_with_changes( &mut self, report: Report<'_>, on_change: impl FnMut(Change<'_>), ) -> Result<(), Error>
Applies a report and delivers all resulting record and app changes.
Removals arrive before each record is removed. Sets arrive after the complete operation, once per new or changed surviving record. Their effective apps include ancestor replacement and eviction effects. Order within removals or sets is unspecified; all removals precede sets.
Equal decoded fields and effective apps produce no set notification.
The report still refreshes update order, just as apply does.
Does not allocate. Change detection copies effective apps into bounded
scratch storage instead of copying complete records.
§Errors
Returns Error::Parser if field preparation fails, before any callback
or mutation. Callbacks are infallible and their effects are not rolled back.
Sourcepub fn on_prompt_with_changes(&mut self, on_change: impl FnMut(Change<'_>))
pub fn on_prompt_with_changes(&mut self, on_change: impl FnMut(Change<'_>))
Removes active records and reports inherited-app changes on survivors.
Uses on_prompt retention rules. All removals precede
sets, which contain the final records and effective apps. Does not allocate.
Sourcepub fn on_process_exit_with_changes(
&mut self,
on_change: impl FnMut(Change<'_>),
)
pub fn on_process_exit_with_changes( &mut self, on_change: impl FnMut(Change<'_>), )
Applies prompt cleanup and change reporting when the attached process exits.
Sourcepub fn on_full_reset_with_changes(&mut self, on_change: impl FnMut(Change<'_>))
pub fn on_full_reset_with_changes(&mut self, on_change: impl FnMut(Change<'_>))
Removes every record on a full terminal reset, delivering only removals.
Source§impl Store<'static>
impl Store<'static>
Sourcepub fn new(capacity: usize) -> Result<Self, Error>
pub fn new(capacity: usize) -> Result<Self, Error>
Creates an empty store with heap storage for capacity records.
Requires the alloc feature. Storage is allocated once and never grows.
Capacities below 64 serve tests but do not meet the host requirement.
§Errors
Returns Error::InvalidCapacity for zero or more than 256 records,
before allocating. Returns Error::Allocation if storage cannot be reserved.
Source§impl<'a> Store<'a>
impl<'a> Store<'a>
Sourcepub fn from_slots(slots: &'a mut [Slot]) -> Result<Self, Error>
pub fn from_slots(slots: &'a mut [Slot]) -> Result<Self, Error>
Borrows caller storage and discards any records previously in the slots.
This constructor does not allocate, including with the alloc feature.
Capacities below 64 serve tests but do not meet the host requirement.
§Errors
Returns Error::InvalidCapacity for zero slots or more than 256 slots,
without changing the supplied storage.
Sourcepub fn get(&self, id: Option<RecordId<'_>>) -> Option<Record<'_>>
pub fn get(&self, id: Option<RecordId<'_>>) -> Option<Record<'_>>
Looks up a root (None) or child record without updating its age.
Sourcepub fn iter(&self) -> impl Iterator<Item = Record<'_>>
pub fn iter(&self) -> impl Iterator<Item = Record<'_>>
Iterates current records. Iteration order is unspecified.
Sourcepub fn effective_app(&self, id: Option<RecordId<'_>>) -> Option<AppId<'_>>
pub fn effective_app(&self, id: Option<RecordId<'_>>) -> Option<AppId<'_>>
Resolves a stored record’s app through its nearest ancestor with an app.
Returns None when the addressed record does not exist or no app applies.
Sourcepub fn apply(&mut self, report: Report<'_>) -> Result<(), Error>
pub fn apply(&mut self, report: Report<'_>) -> Result<(), Error>
Applies a validated report as a complete replacement or subtree clear. A new record at capacity evicts the least recently updated record. Existing-record updates never evict another record. Every set refreshes the record’s update order, even when all fields match.
Does not allocate or collect change notifications.
Use apply_with_changes to observe removals,
replacements, and inherited-app changes.
§Errors
Returns Error::Parser if copying or decoding a field fails. All fields
are prepared before any slot mutation.
Sourcepub fn on_prompt(&mut self)
pub fn on_prompt(&mut self)
Removes working and blocked records when a new shell prompt begins.
Retains idle, done, and error records. Use
on_prompt_with_changes for notifications.
Sourcepub fn on_process_exit(&mut self)
pub fn on_process_exit(&mut self)
Applies prompt cleanup when the process attached to this terminal exits.
This event is not inferred from record ids or child process ids.
Use on_process_exit_with_changes
for notifications.
Sourcepub fn on_full_reset(&mut self)
pub fn on_full_reset(&mut self)
Removes all records on a full terminal reset (RIS).
Use on_full_reset_with_changes
for notifications.