pub struct MemoryStorageSnapshot { /* private fields */ }Expand description
A snapshot of all in-memory state that can be restored later.
This enables rollback functionality similar to SQLite savepoints, allowing you to:
- Create a snapshot before an operation
- Attempt the operation
- Restore the snapshot if the operation fails or needs to be undone
§Concurrency
Snapshot creation and restoration are atomic. create_snapshot() acquires
a global read lock and restore_snapshot() acquires a global write lock,
ensuring consistency in multi-threaded environments.
§Example
ⓘ
let storage = MdkMemoryStorage::default();
// Make some changes
storage.save_group(group)?;
// Create a snapshot (ensure no concurrent operations)
let snapshot = storage.create_snapshot();
// Try an operation that might need rollback
storage.save_message(message)?;
// If we need to undo (ensure no concurrent operations):
storage.restore_snapshot(snapshot);Trait Implementations§
Source§impl Clone for MemoryStorageSnapshot
impl Clone for MemoryStorageSnapshot
Source§fn clone(&self) -> MemoryStorageSnapshot
fn clone(&self) -> MemoryStorageSnapshot
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 moreAuto Trait Implementations§
impl Freeze for MemoryStorageSnapshot
impl RefUnwindSafe for MemoryStorageSnapshot
impl Send for MemoryStorageSnapshot
impl Sync for MemoryStorageSnapshot
impl Unpin for MemoryStorageSnapshot
impl UnsafeUnpin for MemoryStorageSnapshot
impl UnwindSafe for MemoryStorageSnapshot
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
Converts
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>
Converts
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