Skip to main content

Store

Struct Store 

Source
pub struct Store { /* private fields */ }
Expand description

The store.

Implementations§

Source§

impl Store

Source

pub fn snapshots_in(&self, history: &ScopeId) -> Vec<Snapshot>

A history’s snapshots, oldest first.

Experimental: may change in any release (docs/stability.md).
Source

pub fn take_snapshot( &mut self, history: &ScopeId, name: &str, origin: &Origin, dry_run: bool, ) -> Result<Snapshot, Refusal>

Pins the history’s current state under name: the value of every path its steps touched. Never dropped by the cap. With dry_run, the snapshot it would take (id 0), nothing kept.

Experimental: may change in any release (docs/stability.md).
Source

pub fn forget_snapshot(&mut self, history: &ScopeId, id: u64) -> bool

Deletes a snapshot; false when there was none.

Source

pub fn restore_snapshot( &mut self, history: &ScopeId, id: u64, origin: &Origin, dry_run: bool, ) -> Result<Option<Step>, Refusal>

Brings the history back to a snapshot’s state, as one new step (“Restore “name””) that an undo takes back. None: the state is already the snapshot’s. With dry_run, the step it would make (id 0), nothing changed.

Experimental: may change in any release (docs/stability.md).
Source

pub fn undo_step_in( &mut self, history: &ScopeId, id: u64, origin: &Origin, dry_run: bool, ) -> Result<Step, Refusal>

Undoes one step out of order (VS Code’s rule): the head as an undo does; an older step by a new step (“Undo “label””) putting back the values it changed, refused when a later step changed one of them. The step undone; with dry_run, checked only.

Experimental: may change in any release (docs/stability.md).
Source

pub fn replaced_in(&self, history: &ScopeId) -> Vec<(u64, &Step)>

A history’s replaced steps, each with the step its line left after (0: the start), oldest line first, each line oldest first.

Source

pub fn jump_replaced( &mut self, history: &ScopeId, to: u64, origin: &Origin, dry_run: bool, ) -> Result<Option<Vec<Step>>, Refused>

Brings a history to a replaced step: back (or forward) to where its line left, then along it; the current redo list becomes a replaced line in its place. All or nothing. The steps walked, in order; None when to is not a replaced step, or when its line left from a step that is itself replaced (go to that line first). With dry_run, checked and answered, nothing changed.

Source

pub fn values_at( &self, history: &ScopeId, at: At, ) -> Option<Vec<(String, Value, Value)>>

The values that would differ at a point of a history (a step, 0 the start, a replaced step, or a snapshot): each path with its value now and its value there. None: no such point.

Experimental: may change in any release (docs/stability.md).
Source§

impl Store

Source

pub fn new() -> Self

Source

pub fn declare( &mut self, owner: &OwnerId, path: &str, descriptor: Descriptor, ) -> Result<(), DeclareError>

Declares a path at its default value. The same owner may declare a path again (its descriptor is replaced, its value kept when it still fits); another owner may not.

Source

pub fn declare_with( &mut self, owner: &OwnerId, path: &str, descriptor: Descriptor, value: Value, ) -> Result<(), DeclareError>

Declares a path at a value.

Source

pub fn get(&self, path: &str) -> Option<&Entry>

Source

pub fn list(&self, prefix: &str) -> Vec<(&str, &Entry)>

The paths under a prefix (settings/), by path.

Source

pub fn list_in_order(&self, prefix: &str) -> Vec<(&str, &Entry)>

The paths under a prefix, in declaration order.

Source

pub fn seq(&self) -> u64

The store’s sequence number: the last change’s.

Source

pub fn held_by(&self, path: &str) -> Option<&Origin>

The origin of the gesture holding a path, if one does: a widget shows it, an agent knows to wait.

Source

pub fn set_writer_check(&mut self, check: WriterCheck)

What a write from a scope that is not a writer gets: refused or warned about, as WriterCheck says; each path and scope is reported once.

Source

pub fn writer_check(&self) -> WriterCheck

Source

pub fn stray_writes(&self) -> &[StrayWrite]

The writes from scopes that are not writers so far, each path and scope once: what a test of a plugin set expects empty.

Source

pub fn diagnostics(&self) -> &Diagnostics

The store’s diagnostics: writes from scopes that are not writers.

Source

pub fn may_write(&self, path: &str, scope: &OwnerId) -> bool

Whether a scope may write a path (an unknown path: no).

Source

pub fn set(&mut self, set: Set) -> Result<Applied, Refused>

Applies a write. Its scope (Set::by, else current_scope) must be one of the path’s writers: its owner, one its descriptor names (Writers), or the framework; a write naming none is not checked.

Source

pub fn now(&self) -> f64

The store’s clock now (0 without one).

Source

pub fn set_clock(&mut self, clock: Option<SharedClock>)

Where steps take their time from (the interface’s clock); without one, steps are made at 0 and writes never merge.

Source

pub fn has_clock(&self) -> bool

Whether the store has a clock.

Source

pub fn set_place(&mut self, place: Vec<Place>)

The place of the context stack new steps are made in (the interface follows the stack), root first.

Experimental: may change in any release (docs/stability.md).
Source

pub fn seal(&mut self)

The next step of every history starts a new one, even with the head’s merge key (the focus left the target).

Source

pub fn history_cap(&self) -> usize

How many undo steps the store keeps: HISTORY_CAP unless the host set another cap.

Source

pub fn set_history_cap(&mut self, cap: usize)

Keeps at most cap undo steps (and as many redo steps), dropping the oldest now and whenever a new step goes over it. 0 keeps none.

Source

pub fn dropped_steps(&self) -> (u64, u64)

How many undo steps and redo steps the cap dropped from the application’s history (APP) since the store began, each from the front of its list.

Source

pub fn dropped_steps_in(&self, history: &ScopeId) -> (u64, u64)

How many steps the cap dropped from a history.

Source

pub fn histories(&self) -> Vec<ScopeId>

The histories that have had a step, by scope.

Source

pub fn history_rev(&self, history: &ScopeId) -> u64

A history’s revision: it moves on with every change of its lists.

Source

pub fn begin_gesture(&mut self, origin: Origin, label: &str) -> GestureId

Starts a gesture (a drag): its writes are one undo step, and the paths it touches are held against other origins until it ends.

Source

pub fn begin_group(&mut self, origin: Origin, label: &str) -> GestureId

Starts a group: its writes are one undo step, nothing is held.

Source

pub fn end(&mut self, id: GestureId) -> bool

Ends a gesture or a group; what it changed becomes one undo step. Ending one that is not open is reported as false.

Source

pub fn gesture_open(&self, history: &ScopeId) -> Option<&str>

The label of a gesture still going (a drag) whose writes would go to history: an undo there waits for it.

Source

pub fn cancel(&mut self, id: GestureId) -> bool

Cancels a gesture or a group: what it changed is put back as it was (listeners are told), and no undo step is left. Cancelling one that is not open is reported as false.

Source

pub fn take_skipped(&mut self) -> Vec<Skipped>

The values the undos, redos, jumps and cancels since the last call left alone because they had been changed outside the history, each kept with the outside change; the list is emptied.

Source

pub fn take_skipped_in(&mut self, history: &ScopeId) -> Vec<String>

Store::take_skipped for one history: its skipped values are taken, the other histories’ stay.

Source

pub fn undo_steps(&self) -> &[Step]

The application’s undo steps (APP), oldest first.

Source

pub fn redo_steps(&self) -> &[Step]

The application’s redo steps, the next one last.

Source

pub fn undo_steps_in(&self, history: &ScopeId) -> &[Step]

A history’s undo steps, oldest first.

Source

pub fn redo_steps_in(&self, history: &ScopeId) -> &[Step]

A history’s redo steps, the next one last.

Source

pub fn undo(&mut self, origin: &Origin) -> Result<Option<String>, Refused>

Undoes the application’s last step (APP); its label, or None when there is none.

Source

pub fn redo(&mut self, origin: &Origin) -> Result<Option<String>, Refused>

Redoes the application’s last undone step.

Source

pub fn undo_by( &mut self, origin: &Origin, by: &OwnerId, ) -> Result<Option<String>, Refused>

As Store::undo, written by by (Origin::writer): refused, as a write is, when by is not one of the writers of every path the step changed. What an agent’s undo goes through.

Source

pub fn redo_by( &mut self, origin: &Origin, by: &OwnerId, ) -> Result<Option<String>, Refused>

As Store::redo, written by by.

Source

pub fn undo_in( &mut self, history: &ScopeId, origin: &Origin, ) -> Result<Option<Step>, Refused>

Undoes a history’s last step; the step, or None when there is none.

Source

pub fn redo_in( &mut self, history: &ScopeId, origin: &Origin, ) -> Result<Option<Step>, Refused>

Redoes a history’s last undone step.

Source

pub fn undo_in_by( &mut self, history: &ScopeId, origin: &Origin, by: &OwnerId, ) -> Result<Option<Step>, Refused>

As Store::undo_in, written by by (Origin::writer): refused when by is not one of the writers of every path of the step.

Source

pub fn redo_in_by( &mut self, history: &ScopeId, origin: &Origin, by: &OwnerId, ) -> Result<Option<Step>, Refused>

As Store::redo_in, written by by.

Source

pub fn check_walk( &self, history: &ScopeId, redo: bool, ) -> Result<Option<&Step>, Refused>

Whether an undo (or a redo) of a history would be refused, without making it: the step it would take, or None when there is none.

Source

pub fn jump_in( &mut self, history: &ScopeId, to: u64, origin: &Origin, ) -> Result<Option<usize>, Refused>

Brings a history to step to (0: everything undone) by undos or redos, all or none: every step on the way is checked first. How many steps it walked, or None when to is not in the history.

Source

pub fn jump_in_by( &mut self, history: &ScopeId, to: u64, origin: &Origin, by: &OwnerId, ) -> Result<Option<usize>, Refused>

As Store::jump_in, written by by: every step on the way is checked against the writers of its paths first.

Source

pub fn plan_jump(&self, history: &ScopeId, to: u64) -> Option<(bool, usize)>

Redos (true) or undos, and how many, to bring a history to to.

Source

pub fn listen( &mut self, owner: &OwnerId, prefix: &str, f: impl FnMut(&Changed) + Send + 'static, ) -> ListenerId

Calls f after every change of a path starting with prefix (empty: every path), until removed.

Source

pub fn unlisten(&mut self, id: ListenerId) -> bool

Removes a listener; false when it was not there.

Source

pub fn listeners(&self) -> Vec<(ListenerId, &OwnerId, &str)>

The listeners, by id: owner and prefix.

Source

pub fn changes_since(&self, seq: u64) -> Vec<&Changed>

The changes after a sequence number still in the journal.

Source

pub fn remove_owner(&mut self, owner: &OwnerId) -> Vec<String>

Removes an owner’s paths and listeners; their undo steps go too. Changed values of removed paths are kept as pending, so they come back when the owner declares them again. The paths removed; Store::remove_owner_report also says which steps went.

Source

pub fn remove_owner_report(&mut self, owner: &OwnerId) -> OwnerRemoval

Store::remove_owner, saying what went: the paths, and per history the undo steps dropped because they changed one of them, those also changing other owners’ values included (ADR 0028). Each history that lost steps logs how many at info level.

Source

pub fn export(&self, prefix: &str) -> SettingsDoc

The values under a prefix that differ from their default, and the saved values still waiting for their path: what the settings document holds.

Source

pub fn import(&mut self, doc: &SettingsDoc, origin: &Origin) -> Diagnostics

Applies saved values as writes by origin (no undo step). A value for a path not declared yet waits for it; one that does not fit its path is skipped and reported.

Source

pub fn pending(&self) -> &BTreeMap<String, Json>

Saved values waiting for their path to be declared.

Trait Implementations§

Source§

impl Debug for Store

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Store

Source§

fn default() -> Store

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Freeze for Store

§

impl !RefUnwindSafe for Store

§

impl Send for Store

§

impl !Sync for Store

§

impl Unpin for Store

§

impl UnsafeUnpin for Store

§

impl !UnwindSafe for Store

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.