pub struct StorageSnapshotManager { /* private fields */ }Expand description
Production-grade point-in-time snapshot manager with incremental deltas and chain-based restoration.
Implementations§
Source§impl StorageSnapshotManager
impl StorageSnapshotManager
Sourcepub fn new(max_snapshots: usize) -> Self
pub fn new(max_snapshots: usize) -> Self
Create a new, empty manager.
max_snapshots controls how many snapshots are retained before the
oldest is evicted to make room for a new one.
Sourcepub fn put(&mut self, key: String, value: Vec<u8>, _now: u64)
pub fn put(&mut self, key: String, value: Vec<u8>, _now: u64)
Insert or update a key in the live state.
The entry’s version is set to self.next_version (then incremented).
Sourcepub fn delete(&mut self, key: &str) -> bool
pub fn delete(&mut self, key: &str) -> bool
Remove a key from the live state.
Returns false if the key was not present.
Sourcepub fn get(&self, key: &str) -> Option<&[u8]>
pub fn get(&self, key: &str) -> Option<&[u8]>
Look up the value bytes for a key in the live state.
Sourcepub fn take_snapshot(&mut self, label: Option<String>, now: u64) -> SnapshotId
pub fn take_snapshot(&mut self, label: Option<String>, now: u64) -> SnapshotId
Capture the current live state as a new snapshot.
- If this is the first snapshot, it is a full snapshot (
deltaisNone). - Otherwise, a delta relative to the preceding snapshot is computed.
If the queue is already at max_snapshots, the oldest snapshot is
evicted before appending the new one.
Sourcepub fn restore_snapshot(&mut self, id: SnapshotId) -> Result<(), SnapshotError>
pub fn restore_snapshot(&mut self, id: SnapshotId) -> Result<(), SnapshotError>
Restore the live state to the point captured by snapshot id.
The state stored inline in the snapshot is used directly (O(1) after locating the snapshot in the deque).
Sourcepub fn list_snapshots(&self) -> Vec<&SsmSnapshot>
pub fn list_snapshots(&self) -> Vec<&SsmSnapshot>
Return all retained snapshots ordered oldest to newest.
Sourcepub fn get_snapshot(&self, id: SnapshotId) -> Option<&SsmSnapshot>
pub fn get_snapshot(&self, id: SnapshotId) -> Option<&SsmSnapshot>
Look up a snapshot by id.
Sourcepub fn delete_snapshot(&mut self, id: SnapshotId) -> Result<(), SnapshotError>
pub fn delete_snapshot(&mut self, id: SnapshotId) -> Result<(), SnapshotError>
Remove the oldest snapshot from the queue.
Returns CannotDeleteNonOldest if id does not refer to the oldest
snapshot, and SnapshotNotFound if no snapshot with id exists.
Sourcepub fn diff_snapshots(
&self,
a: SnapshotId,
b: SnapshotId,
) -> Result<SnapshotDelta, SnapshotError>
pub fn diff_snapshots( &self, a: SnapshotId, b: SnapshotId, ) -> Result<SnapshotDelta, SnapshotError>
Compute the full state diff between two snapshots.
Reconstructs both states from the stored inline state, then compares.
Sourcepub fn snapshot_count(&self) -> usize
pub fn snapshot_count(&self) -> usize
Number of snapshots currently retained.
Sourcepub fn live_entry_count(&self) -> usize
pub fn live_entry_count(&self) -> usize
Number of entries in the current live state.
Sourcepub fn live_total_bytes(&self) -> u64
pub fn live_total_bytes(&self) -> u64
Sum of value byte sizes in the current live state.
Sourcepub fn stats(&self) -> SnapshotStats
pub fn stats(&self) -> SnapshotStats
Return aggregate statistics.
Auto Trait Implementations§
impl Freeze for StorageSnapshotManager
impl RefUnwindSafe for StorageSnapshotManager
impl Send for StorageSnapshotManager
impl Sync for StorageSnapshotManager
impl Unpin for StorageSnapshotManager
impl UnsafeUnpin for StorageSnapshotManager
impl UnwindSafe for StorageSnapshotManager
Blanket Implementations§
impl<T> Allocation for T
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more