pub struct SyncStateManager<'a> { /* private fields */ }Expand description
Manages sync state persistence in the sync tree.
Implementations§
Source§impl<'a> SyncStateManager<'a>
impl<'a> SyncStateManager<'a>
Sourcepub fn new(txn: &'a Transaction) -> Self
pub fn new(txn: &'a Transaction) -> Self
Create a new sync state manager.
Sourcepub async fn get_sync_cursor(
&self,
peer_pubkey: &PublicKey,
tree_id: &ID,
clock: &dyn Clock,
) -> Result<SyncCursor>
pub async fn get_sync_cursor( &self, peer_pubkey: &PublicKey, tree_id: &ID, clock: &dyn Clock, ) -> Result<SyncCursor>
Get or create a sync cursor for a peer-tree relationship.
§Arguments
peer_pubkey- The peer’s public keytree_id- The tree ID this cursor applies toclock- The time provider for timestamps (used when creating new cursor)
Sourcepub async fn update_sync_cursor(&self, cursor: &SyncCursor) -> Result<()>
pub async fn update_sync_cursor(&self, cursor: &SyncCursor) -> Result<()>
Update a sync cursor.
Sourcepub async fn get_sync_metadata(
&self,
peer_pubkey: &PublicKey,
clock: &dyn Clock,
) -> Result<SyncMetadata>
pub async fn get_sync_metadata( &self, peer_pubkey: &PublicKey, clock: &dyn Clock, ) -> Result<SyncMetadata>
Get or create sync metadata for a peer.
§Arguments
peer_pubkey- The peer’s public keyclock- The time provider for timestamps (used when creating new metadata)
Sourcepub async fn update_sync_metadata(&self, metadata: &SyncMetadata) -> Result<()>
pub async fn update_sync_metadata(&self, metadata: &SyncMetadata) -> Result<()>
Update sync metadata for a peer.
Sourcepub async fn add_sync_history(
&self,
history_entry: &SyncHistoryEntry,
) -> Result<()>
pub async fn add_sync_history( &self, history_entry: &SyncHistoryEntry, ) -> Result<()>
Add a sync history entry.
Sourcepub async fn get_sync_history(
&self,
peer_pubkey: &PublicKey,
limit: Option<usize>,
) -> Result<Vec<SyncHistoryEntry>>
pub async fn get_sync_history( &self, peer_pubkey: &PublicKey, limit: Option<usize>, ) -> Result<Vec<SyncHistoryEntry>>
Get sync history for a peer, optionally limited to recent entries.
§Implementation Note
This method navigates the nested map structure created by DocStore::set_path().
When using set_path("history.sync_id", data), it creates a nested structure
{ "history": { "sync_id": data } } rather than a flat key with dots.
Sourcepub async fn get_peers_with_sync_state(&self) -> Result<Vec<PublicKey>>
pub async fn get_peers_with_sync_state(&self) -> Result<Vec<PublicKey>>
Get all peers with sync state.
§Implementation Note
This method navigates the nested map structure created by DocStore::set_path().
The data is organized in nested maps like { "metadata": { "peer_key": data } }
and { "cursors": { "peer_key": { "tree_id": data } } }.
Sourcepub async fn cleanup_old_history(
&self,
max_age_days: u32,
clock: &dyn Clock,
) -> Result<usize>
pub async fn cleanup_old_history( &self, max_age_days: u32, clock: &dyn Clock, ) -> Result<usize>
Clean up old sync history entries.
§Arguments
max_age_days- Maximum age of history entries to keep (older entries are deleted)clock- The time provider for determining current time
§Implementation Note
This method navigates the nested map structure created by DocStore::set_path().
History entries are stored as { "history": { "sync_id": data } } and the
method properly navigates this structure to find and clean old entries.
Auto Trait Implementations§
impl<'a> Freeze for SyncStateManager<'a>
impl<'a> !RefUnwindSafe for SyncStateManager<'a>
impl<'a> Send for SyncStateManager<'a>
impl<'a> Sync for SyncStateManager<'a>
impl<'a> Unpin for SyncStateManager<'a>
impl<'a> !UnwindSafe for SyncStateManager<'a>
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
§impl<T> CompatExt for T
impl<T> CompatExt for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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