pub struct SyncStatePersistence { /* private fields */ }Expand description
Sync state persistence manager
Provides durable storage for Automerge sync state to enable fast recovery after restart without full resync.
Implementations§
Source§impl SyncStatePersistence
impl SyncStatePersistence
Sourcepub fn open(path: impl AsRef<Path>) -> Result<SyncStatePersistence, Error>
pub fn open(path: impl AsRef<Path>) -> Result<SyncStatePersistence, Error>
Open or create sync state storage at the given path
Sourcepub fn open_with_interval(
path: impl AsRef<Path>,
checkpoint_interval: Duration,
) -> Result<SyncStatePersistence, Error>
pub fn open_with_interval( path: impl AsRef<Path>, checkpoint_interval: Duration, ) -> Result<SyncStatePersistence, Error>
Open with custom checkpoint interval
Sourcepub fn save_sync_state(
&self,
peer_id: &PublicKey,
doc_key: &str,
state: &State,
sync_count: u64,
) -> Result<(), Error>
pub fn save_sync_state( &self, peer_id: &PublicKey, doc_key: &str, state: &State, sync_count: u64, ) -> Result<(), Error>
Save sync state for a peer and document
Sourcepub fn load_sync_state(
&self,
peer_id: &PublicKey,
doc_key: &str,
) -> Result<Option<(State, u64)>, Error>
pub fn load_sync_state( &self, peer_id: &PublicKey, doc_key: &str, ) -> Result<Option<(State, u64)>, Error>
Load sync state for a peer and document
Sourcepub fn delete_sync_state(
&self,
peer_id: &PublicKey,
doc_key: &str,
) -> Result<(), Error>
pub fn delete_sync_state( &self, peer_id: &PublicKey, doc_key: &str, ) -> Result<(), Error>
Delete sync state for a peer and document
Sourcepub fn load_all_for_peer(
&self,
peer_id: &PublicKey,
) -> Result<HashMap<String, State>, Error>
pub fn load_all_for_peer( &self, peer_id: &PublicKey, ) -> Result<HashMap<String, State>, Error>
Load all sync states for a peer
Sourcepub fn load_all(&self) -> Result<HashMap<(PublicKey, String), State>, Error>
pub fn load_all(&self) -> Result<HashMap<(PublicKey, String), State>, Error>
Load all sync states (for full recovery)
Sourcepub fn create_checkpoint(&self) -> Result<Checkpoint, Error>
pub fn create_checkpoint(&self) -> Result<Checkpoint, Error>
Create a checkpoint
Sourcepub fn get_last_checkpoint(&self) -> Result<Option<Checkpoint>, Error>
pub fn get_last_checkpoint(&self) -> Result<Option<Checkpoint>, Error>
Get the last checkpoint
Sourcepub fn stats(&self) -> Result<PersistenceStats, Error>
pub fn stats(&self) -> Result<PersistenceStats, Error>
Get persistence statistics
Sourcepub fn cleanup_old_checkpoints(&self, keep_count: usize) -> Result<usize, Error>
pub fn cleanup_old_checkpoints(&self, keep_count: usize) -> Result<usize, Error>
Clean up old checkpoints, keeping only the last N
Sourcepub fn delete_peer(&self, peer_id: &PublicKey) -> Result<usize, Error>
pub fn delete_peer(&self, peer_id: &PublicKey) -> Result<usize, Error>
Delete all sync state for a peer (when peer is removed from mesh)
Sourcepub fn checkpoint_interval(&self) -> Duration
pub fn checkpoint_interval(&self) -> Duration
Get checkpoint interval
Auto Trait Implementations§
impl Freeze for SyncStatePersistence
impl !RefUnwindSafe for SyncStatePersistence
impl Send for SyncStatePersistence
impl Sync for SyncStatePersistence
impl Unpin for SyncStatePersistence
impl UnsafeUnpin for SyncStatePersistence
impl !UnwindSafe for SyncStatePersistence
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> 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>
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