pub struct Store { /* private fields */ }Expand description
The store.
Implementations§
Source§impl Store
impl Store
Sourcepub fn snapshots_in(&self, history: &ScopeId) -> Vec<Snapshot>
pub fn snapshots_in(&self, history: &ScopeId) -> Vec<Snapshot>
A history’s snapshots, oldest first.
Sourcepub fn take_snapshot(
&mut self,
history: &ScopeId,
name: &str,
origin: &Origin,
dry_run: bool,
) -> Result<Snapshot, Refusal>
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.
Sourcepub fn forget_snapshot(&mut self, history: &ScopeId, id: u64) -> bool
pub fn forget_snapshot(&mut self, history: &ScopeId, id: u64) -> bool
Deletes a snapshot; false when there was none.
Sourcepub fn restore_snapshot(
&mut self,
history: &ScopeId,
id: u64,
origin: &Origin,
dry_run: bool,
) -> Result<Option<Step>, Refusal>
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.
Sourcepub fn undo_step_in(
&mut self,
history: &ScopeId,
id: u64,
origin: &Origin,
dry_run: bool,
) -> Result<Step, Refusal>
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.
Sourcepub fn replaced_in(&self, history: &ScopeId) -> Vec<(u64, &Step)>
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.
Sourcepub fn jump_replaced(
&mut self,
history: &ScopeId,
to: u64,
origin: &Origin,
dry_run: bool,
) -> Result<Option<Vec<Step>>, Refused>
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.
Sourcepub fn values_at(
&self,
history: &ScopeId,
at: At,
) -> Option<Vec<(String, Value, Value)>>
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.
Source§impl Store
impl Store
pub fn new() -> Self
Sourcepub fn declare(
&mut self,
owner: &OwnerId,
path: &str,
descriptor: Descriptor,
) -> Result<(), DeclareError>
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.
Sourcepub fn declare_with(
&mut self,
owner: &OwnerId,
path: &str,
descriptor: Descriptor,
value: Value,
) -> Result<(), DeclareError>
pub fn declare_with( &mut self, owner: &OwnerId, path: &str, descriptor: Descriptor, value: Value, ) -> Result<(), DeclareError>
Declares a path at a value.
pub fn get(&self, path: &str) -> Option<&Entry>
Sourcepub fn list(&self, prefix: &str) -> Vec<(&str, &Entry)>
pub fn list(&self, prefix: &str) -> Vec<(&str, &Entry)>
The paths under a prefix (settings/), by path.
Sourcepub fn list_in_order(&self, prefix: &str) -> Vec<(&str, &Entry)>
pub fn list_in_order(&self, prefix: &str) -> Vec<(&str, &Entry)>
The paths under a prefix, in declaration order.
Sourcepub fn held_by(&self, path: &str) -> Option<&Origin>
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.
Sourcepub fn set_writer_check(&mut self, check: WriterCheck)
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.
pub fn writer_check(&self) -> WriterCheck
Sourcepub fn stray_writes(&self) -> &[StrayWrite]
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.
Sourcepub fn diagnostics(&self) -> &Diagnostics
pub fn diagnostics(&self) -> &Diagnostics
The store’s diagnostics: writes from scopes that are not writers.
Sourcepub fn may_write(&self, path: &str, scope: &OwnerId) -> bool
pub fn may_write(&self, path: &str, scope: &OwnerId) -> bool
Whether a scope may write a path (an unknown path: no).
Sourcepub fn set(&mut self, set: Set) -> Result<Applied, Refused>
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.
Sourcepub fn set_clock(&mut self, clock: Option<SharedClock>)
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.
Sourcepub fn set_place(&mut self, place: Vec<Place>)
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.
Sourcepub fn seal(&mut self)
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).
Sourcepub fn history_cap(&self) -> usize
pub fn history_cap(&self) -> usize
How many undo steps the store keeps: HISTORY_CAP unless the
host set another cap.
Sourcepub fn set_history_cap(&mut self, cap: usize)
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.
Sourcepub fn dropped_steps(&self) -> (u64, u64)
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.
Sourcepub fn dropped_steps_in(&self, history: &ScopeId) -> (u64, u64)
pub fn dropped_steps_in(&self, history: &ScopeId) -> (u64, u64)
How many steps the cap dropped from a history.
Sourcepub fn history_rev(&self, history: &ScopeId) -> u64
pub fn history_rev(&self, history: &ScopeId) -> u64
A history’s revision: it moves on with every change of its lists.
Sourcepub fn begin_gesture(&mut self, origin: Origin, label: &str) -> GestureId
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.
Sourcepub fn begin_group(&mut self, origin: Origin, label: &str) -> GestureId
pub fn begin_group(&mut self, origin: Origin, label: &str) -> GestureId
Starts a group: its writes are one undo step, nothing is held.
Sourcepub fn end(&mut self, id: GestureId) -> bool
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.
Sourcepub fn gesture_open(&self, history: &ScopeId) -> Option<&str>
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.
Sourcepub fn cancel(&mut self, id: GestureId) -> bool
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.
Sourcepub fn take_skipped(&mut self) -> Vec<Skipped>
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.
Sourcepub fn take_skipped_in(&mut self, history: &ScopeId) -> Vec<String>
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.
Sourcepub fn undo_steps(&self) -> &[Step]
pub fn undo_steps(&self) -> &[Step]
The application’s undo steps (APP), oldest first.
Sourcepub fn redo_steps(&self) -> &[Step]
pub fn redo_steps(&self) -> &[Step]
The application’s redo steps, the next one last.
Sourcepub fn undo_steps_in(&self, history: &ScopeId) -> &[Step]
pub fn undo_steps_in(&self, history: &ScopeId) -> &[Step]
A history’s undo steps, oldest first.
Sourcepub fn redo_steps_in(&self, history: &ScopeId) -> &[Step]
pub fn redo_steps_in(&self, history: &ScopeId) -> &[Step]
A history’s redo steps, the next one last.
Sourcepub fn undo(&mut self, origin: &Origin) -> Result<Option<String>, Refused>
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.
Sourcepub fn redo(&mut self, origin: &Origin) -> Result<Option<String>, Refused>
pub fn redo(&mut self, origin: &Origin) -> Result<Option<String>, Refused>
Redoes the application’s last undone step.
Sourcepub fn undo_by(
&mut self,
origin: &Origin,
by: &OwnerId,
) -> Result<Option<String>, Refused>
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.
Sourcepub fn redo_by(
&mut self,
origin: &Origin,
by: &OwnerId,
) -> Result<Option<String>, Refused>
pub fn redo_by( &mut self, origin: &Origin, by: &OwnerId, ) -> Result<Option<String>, Refused>
As Store::redo, written by by.
Sourcepub fn undo_in(
&mut self,
history: &ScopeId,
origin: &Origin,
) -> Result<Option<Step>, Refused>
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.
Sourcepub fn redo_in(
&mut self,
history: &ScopeId,
origin: &Origin,
) -> Result<Option<Step>, Refused>
pub fn redo_in( &mut self, history: &ScopeId, origin: &Origin, ) -> Result<Option<Step>, Refused>
Redoes a history’s last undone step.
Sourcepub fn undo_in_by(
&mut self,
history: &ScopeId,
origin: &Origin,
by: &OwnerId,
) -> Result<Option<Step>, Refused>
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.
Sourcepub fn redo_in_by(
&mut self,
history: &ScopeId,
origin: &Origin,
by: &OwnerId,
) -> Result<Option<Step>, Refused>
pub fn redo_in_by( &mut self, history: &ScopeId, origin: &Origin, by: &OwnerId, ) -> Result<Option<Step>, Refused>
As Store::redo_in, written by by.
Sourcepub fn check_walk(
&self,
history: &ScopeId,
redo: bool,
) -> Result<Option<&Step>, Refused>
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.
Sourcepub fn jump_in(
&mut self,
history: &ScopeId,
to: u64,
origin: &Origin,
) -> Result<Option<usize>, Refused>
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.
Sourcepub fn jump_in_by(
&mut self,
history: &ScopeId,
to: u64,
origin: &Origin,
by: &OwnerId,
) -> Result<Option<usize>, Refused>
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.
Sourcepub fn plan_jump(&self, history: &ScopeId, to: u64) -> Option<(bool, usize)>
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.
Sourcepub fn listen(
&mut self,
owner: &OwnerId,
prefix: &str,
f: impl FnMut(&Changed) + Send + 'static,
) -> ListenerId
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.
Sourcepub fn unlisten(&mut self, id: ListenerId) -> bool
pub fn unlisten(&mut self, id: ListenerId) -> bool
Removes a listener; false when it was not there.
Sourcepub fn listeners(&self) -> Vec<(ListenerId, &OwnerId, &str)>
pub fn listeners(&self) -> Vec<(ListenerId, &OwnerId, &str)>
The listeners, by id: owner and prefix.
Sourcepub fn changes_since(&self, seq: u64) -> Vec<&Changed>
pub fn changes_since(&self, seq: u64) -> Vec<&Changed>
The changes after a sequence number still in the journal.
Sourcepub fn remove_owner(&mut self, owner: &OwnerId) -> Vec<String>
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.
Sourcepub fn remove_owner_report(&mut self, owner: &OwnerId) -> OwnerRemoval
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.
Sourcepub fn export(&self, prefix: &str) -> SettingsDoc
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.
Sourcepub fn import(&mut self, doc: &SettingsDoc, origin: &Origin) -> Diagnostics
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.