pub struct PaneVersionStore { /* private fields */ }Expand description
A history of pane-tree versions with replay-free undo/redo.
undo/redo/current are O(1) — they move or read a cursor over a Vec
of immutable version roots. Applying a new operation truncates any redo
branch (matching the canonical timeline) and appends a new version.
Implementations§
Source§impl PaneVersionStore
impl PaneVersionStore
Sourcepub fn new(initial: VersionedPaneTree) -> Self
pub fn new(initial: VersionedPaneTree) -> Self
Create a store seeded with an initial version (the baseline).
Sourcepub fn with_max_versions(
initial: VersionedPaneTree,
max_versions: usize,
) -> Self
pub fn with_max_versions( initial: VersionedPaneTree, max_versions: usize, ) -> Self
Create a store with a bounded retention window.
When the retained version count exceeds max_versions, the oldest
versions are pruned (which discards the ability to undo into them, the
same posture as the canonical timeline’s entry limit). 0 is unbounded.
Sourcepub fn set_max_versions(&mut self, max_versions: usize) -> usize
pub fn set_max_versions(&mut self, max_versions: usize) -> usize
Install a retention bound and immediately enforce it, pruning the oldest
versions if the store currently exceeds max_versions.
Unlike with_max_versions this acts on an
existing store, so a retention policy can re-bound it retroactively.
Pruning never reaches the cursor: the current version — and therefore
current’s state hash — plus the redo tail always
survive, so after a deep undo the store may retain more than
max_versions until the cursor advances again. Returns the number of
versions pruned by this call (possibly 0 when the cursor pins all
history). 0 is unbounded.
Sourcepub fn apply(
&mut self,
operation: &PaneOperation,
) -> Result<&VersionedPaneTree, PersistentApplyError>
pub fn apply( &mut self, operation: &PaneOperation, ) -> Result<&VersionedPaneTree, PersistentApplyError>
Apply an operation to the current version, appending a new version.
§Errors
Propagates the PersistentApplyError from the underlying apply.
Sourcepub fn undo(&mut self) -> bool
pub fn undo(&mut self) -> bool
Move to the previous version. Returns false at the oldest retained version.
Sourcepub fn current(&self) -> &VersionedPaneTree
pub fn current(&self) -> &VersionedPaneTree
The current version.
Sourcepub fn version_count(&self) -> usize
pub fn version_count(&self) -> usize
Number of retained versions.
Sourcepub fn report(&self) -> PaneVersioningReport
pub fn report(&self) -> PaneVersioningReport
Compute a structural-sharing and memory-retention report.
Sourcepub fn retention(&self) -> PaneVersionRetention
pub fn retention(&self) -> PaneVersionRetention
Compute a deterministic retained-memory byte model over the distinct nodes physically held by all retained versions.
The model mirrors the canonical timeline’s
retention_diagnostics
methodology — size_of struct estimates plus measured string payload
bytes — so the two strategies are directly comparable. Because shared
subtrees are counted once (via Arc pointer identity), node bytes scale
with distinct nodes, not the logical node total. Tree-level extension
maps are owned separately by each version and are counted per version.
This is a payload model, not an allocator measurement: spare capacity
and allocation bookkeeping are not included.