pub struct DeltaChannel<T, R: Reducer<T>> { /* private fields */ }Expand description
Delta channel: append-heavy optimization with periodic snapshots
Tracks updates since the last snapshot and can replay writes for
restoring from a delta-based checkpoint. The snapshot_frequency
controls how often a full snapshot is taken instead of just recording
the delta.
Implementations§
Source§impl<T, R: Reducer<T>> DeltaChannel<T, R>
impl<T, R: Reducer<T>> DeltaChannel<T, R>
Sourcepub fn new(value: T, snapshot_frequency: usize) -> Self
pub fn new(value: T, snapshot_frequency: usize) -> Self
Create a new delta channel with the given initial value and snapshot frequency
The snapshot frequency is clamped to a minimum of 1.
Sourcepub fn replay_writes(&mut self, values: &[T])
pub fn replay_writes(&mut self, values: &[T])
Replay a sequence of writes to restore state from a checkpoint
During checkpoint recovery, finds the last Overwrite<T> in the sequence
and uses it as the baseline, then applies only the writes after it via
the reducer. This implements the design specification for ancestor replay.
Sourcepub const fn should_snapshot(&self) -> bool
pub const fn should_snapshot(&self) -> bool
Check if a snapshot is due based on the update count
Trait Implementations§
Source§impl<T, R> Channel<T> for DeltaChannel<T, R>
impl<T, R> Channel<T> for DeltaChannel<T, R>
Source§fn update(&mut self, values: Vec<T>) -> bool
fn update(&mut self, values: Vec<T>) -> bool
Update the channel with new values. Returns true if the value changed.
Source§fn consume(&mut self) -> bool
fn consume(&mut self) -> bool
Check if the channel has been consumed (for trigger-based activation)
Source§fn checkpoint(&self) -> Option<Value>
fn checkpoint(&self) -> Option<Value>
Create a checkpoint of the current value for persistence
Auto Trait Implementations§
impl<T, R> Freeze for DeltaChannel<T, R>where
T: Freeze,
impl<T, R> RefUnwindSafe for DeltaChannel<T, R>where
T: RefUnwindSafe,
R: RefUnwindSafe,
impl<T, R> Send for DeltaChannel<T, R>
impl<T, R> Sync for DeltaChannel<T, R>
impl<T, R> Unpin for DeltaChannel<T, R>
impl<T, R> UnsafeUnpin for DeltaChannel<T, R>where
T: UnsafeUnpin,
impl<T, R> UnwindSafe for DeltaChannel<T, R>where
T: UnwindSafe,
R: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more