Skip to main content

PaneVersionStore

Struct PaneVersionStore 

Source
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

Source

pub fn new(initial: VersionedPaneTree) -> Self

Create a store seeded with an initial version (the baseline).

Source

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.

Source

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.

Source

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.

Source

pub fn undo(&mut self) -> bool

Move to the previous version. Returns false at the oldest retained version.

Source

pub fn redo(&mut self) -> bool

Move to the next version. Returns false at the newest version.

Source

pub fn current(&self) -> &VersionedPaneTree

The current version.

Source

pub fn version_count(&self) -> usize

Number of retained versions.

Source

pub const fn cursor(&self) -> usize

Current cursor index.

Source

pub const fn can_undo(&self) -> bool

Whether undo would succeed.

Source

pub fn can_redo(&self) -> bool

Whether redo would succeed.

Source

pub const fn pruned(&self) -> usize

Number of versions pruned by the retention bound so far.

Source

pub fn report(&self) -> PaneVersioningReport

Compute a structural-sharing and memory-retention report.

Source

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.

Trait Implementations§

Source§

impl Clone for PaneVersionStore

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for PaneVersionStore

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.