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
impl ZwinderStateManager
Sourcepub fn new(budget_bytes: usize, keyframe_interval: u32) -> Self
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).
Sourcepub fn store(&mut self, frame: u64, snapshot: &[u8], cursor: u64)
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.
Sourcepub fn nearest_at_or_before(
&self,
target: u64,
) -> Option<Result<(u64, Vec<u8>), ZwinderError>>
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.
Sourcepub fn get(&self, frame: u64) -> Option<Result<Vec<u8>, ZwinderError>>
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.
Sourcepub fn invalidate_after(&mut self, frame: u64)
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.
Sourcepub fn add_anchor(&mut self, frame: u64)
pub fn add_anchor(&mut self, frame: u64)
Register frame as a permanent anchor (never evicted, always a
keyframe once stored).
Sourcepub fn remove_anchor(&mut self, frame: u64)
pub fn remove_anchor(&mut self, frame: u64)
Remove an anchor registration (frame 0 stays anchored regardless).
Sourcepub fn clear_non_default_anchors(&mut self)
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).
Sourcepub const fn used_bytes(&self) -> usize
pub const fn used_bytes(&self) -> usize
Total compressed bytes currently held.
Sourcepub const fn budget_bytes(&self) -> usize
pub const fn budget_bytes(&self) -> usize
The compressed byte budget eviction targets.
Sourcepub fn cached_frames(&self) -> impl Iterator<Item = u64> + '_
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.