Skip to main content

Store

Struct Store 

Source
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<'_>

Source

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.

Source

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.

Source

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.

Source

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>

Source

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>

Source

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.

Source

pub fn len(&self) -> usize

Returns the number of current records, including root.

Source

pub const fn is_empty(&self) -> bool

Returns whether there are no current records.

Source

pub const fn capacity(&self) -> usize

Returns the caller-selected record capacity.

Source

pub fn get(&self, id: Option<RecordId<'_>>) -> Option<Record<'_>>

Looks up a root (None) or child record without updating its age.

Source

pub fn iter(&self) -> impl Iterator<Item = Record<'_>>

Iterates current records. Iteration order is unspecified.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn on_full_reset(&mut self)

Removes all records on a full terminal reset (RIS). Use on_full_reset_with_changes for notifications.

Auto Trait Implementations§

§

impl<'a> !UnwindSafe for Store<'a>

§

impl<'a> Freeze for Store<'a>

§

impl<'a> RefUnwindSafe for Store<'a>

§

impl<'a> Send for Store<'a>

§

impl<'a> Sync for Store<'a>

§

impl<'a> Unpin for Store<'a>

§

impl<'a> UnsafeUnpin for Store<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.