Skip to main content

ZwinderStateManager

Struct ZwinderStateManager 

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

A compressed, density-tiered, byte-budgeted history of frame-keyed save-states. See the module docs for the design.

Implementations§

Source§

impl ZwinderStateManager

Source

pub fn new(budget_bytes: usize, keyframe_interval: u32) -> Self

Create an empty manager with a compressed byte budget and keyframe interval. Frame 0 is always an anchor (the power-on base must never be evicted). keyframe_interval of 0 is treated as 1 (every entry a keyframe).

Source

pub fn store(&mut self, frame: u64, snapshot: &[u8], cursor: u64)

Store (or replace) the save-state for frame, compressing it. cursor is the editor/playhead frame — eviction protects the dense neighbourhood around it. Enforces the byte budget after inserting.

Anchored frames are always stored as self-contained keyframes (so they never depend on a neighbour that eviction might thin). A non-anchor frame is a delta against the nearest preceding keyframe, unless none exists at-or-before it or the keyframe interval is due — then it is promoted to a keyframe.

Source

pub fn nearest_at_or_before( &self, target: u64, ) -> Option<Result<(u64, Vec<u8>), ZwinderError>>

Decode and return the nearest cached state at or before target, as (frame, snapshot_bytes). None if nothing at-or-before target is cached.

§Errors

Returns ZwinderError if the entry (or the keyframe a delta depends on) can’t be reconstructed.

Source

pub fn get(&self, frame: u64) -> Option<Result<Vec<u8>, ZwinderError>>

Decode and return the cached state for exactly frame, if present.

§Errors

Returns ZwinderError if the entry can’t be reconstructed.

Source

pub fn has(&self, frame: u64) -> bool

true if a state is cached for exactly frame.

Source

pub fn invalidate_after(&mut self, frame: u64)

Drop every cached state strictly after frame (the InvalidateAfter operation — an edit at frame invalidates the downstream tail). Anchor registrations after frame are kept (a later recapture re-pins them), but their stored state is dropped.

Source

pub fn add_anchor(&mut self, frame: u64)

Register frame as a permanent anchor (never evicted, always a keyframe once stored).

Source

pub fn remove_anchor(&mut self, frame: u64)

Remove an anchor registration (frame 0 stays anchored regardless).

Source

pub fn is_anchor(&self, frame: u64) -> bool

true if frame is a permanent anchor.

Source

pub fn clear_non_default_anchors(&mut self)

Drop every anchor except frame 0 (used when the marker set is rebuilt wholesale — a branch load or project load).

Source

pub fn clear(&mut self)

Drop all cached states (anchor registrations are kept).

Source

pub const fn len(&self) -> usize

Number of cached frames.

Source

pub const fn is_empty(&self) -> bool

true if no states are cached.

Source

pub const fn used_bytes(&self) -> usize

Total compressed bytes currently held.

Source

pub const fn budget_bytes(&self) -> usize

The compressed byte budget eviction targets.

Source

pub fn cached_frames(&self) -> impl Iterator<Item = u64> + '_

The set of frames a state is cached for (ascending). Used to colour greenzone-resident rows.

Trait Implementations§

Source§

impl Debug for ZwinderStateManager

Source§

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

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

impl Default for ZwinderStateManager

Source§

fn default() -> Self

Returns the “default value” for a type. 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<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> Same for T

Source§

type Output = T

Should always be Self
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.