pub struct SnapshotPersistence { /* private fields */ }Expand description
Manages reading and writing AppStateSnapshot to disk.
Implementations§
Source§impl SnapshotPersistence
impl SnapshotPersistence
Sourcepub fn with_dir(dir: impl Into<PathBuf>) -> Self
pub fn with_dir(dir: impl Into<PathBuf>) -> Self
Create a persistence manager using a custom directory (useful for tests).
Sourcepub fn snapshot_path(&self, session_id: &str) -> PathBuf
pub fn snapshot_path(&self, session_id: &str) -> PathBuf
Return the path where a session’s snapshot would be stored.
Sourcepub fn save(&self, snapshot: &AppStateSnapshot) -> Result<(), String>
pub fn save(&self, snapshot: &AppStateSnapshot) -> Result<(), String>
Save a snapshot to disk atomically (write tmp then rename).
Sourcepub fn load(&self, session_id: &str) -> Option<AppStateSnapshot>
pub fn load(&self, session_id: &str) -> Option<AppStateSnapshot>
Load a snapshot for a specific session.
Sourcepub fn find_incomplete_sessions(&self) -> Vec<AppStateSnapshot>
pub fn find_incomplete_sessions(&self) -> Vec<AppStateSnapshot>
Find all incomplete (non-completed) session snapshots.
Returns snapshots where completed == false, sorted by timestamp
(most recent first).
Sourcepub fn remove(&self, session_id: &str) -> bool
pub fn remove(&self, session_id: &str) -> bool
Remove the snapshot file for a session (e.g., after clean exit or recovery).
Sourcepub fn cleanup_old(&self, max_age: Duration) -> usize
pub fn cleanup_old(&self, max_age: Duration) -> usize
Remove snapshots older than max_age.
Trait Implementations§
Source§impl Clone for SnapshotPersistence
impl Clone for SnapshotPersistence
Source§fn clone(&self) -> SnapshotPersistence
fn clone(&self) -> SnapshotPersistence
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for SnapshotPersistence
impl Debug for SnapshotPersistence
Auto Trait Implementations§
impl Freeze for SnapshotPersistence
impl RefUnwindSafe for SnapshotPersistence
impl Send for SnapshotPersistence
impl Sync for SnapshotPersistence
impl Unpin for SnapshotPersistence
impl UnsafeUnpin for SnapshotPersistence
impl UnwindSafe for SnapshotPersistence
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