pub struct SyncState {
pub crdt_format: CrdtFormat,
pub crdt_version: Option<String>,
pub sync_version: Option<u64>,
pub last_sync: Option<DateTime<Utc>>,
pub peers: Vec<Peer>,
}Expand description
Synchronization state for CRDT-based collaboration.
Tracks the current sync state of a document for real-time collaboration.
Fields§
§crdt_format: CrdtFormatCRDT format being used.
crdt_version: Option<String>Version of the CRDT library.
sync_version: Option<u64>Logical clock or sequence number for sync state.
last_sync: Option<DateTime<Utc>>Timestamp of last synchronization.
peers: Vec<Peer>Known collaboration peers.
Implementations§
Source§impl SyncState
impl SyncState
Sourcepub fn new(crdt_format: CrdtFormat) -> Self
pub fn new(crdt_format: CrdtFormat) -> Self
Create new sync state with the specified CRDT format.
Sourcepub fn diamond_types() -> Self
pub fn diamond_types() -> Self
Create sync state for Diamond Types.
Sourcepub fn with_version(self, version: impl Into<String>) -> Self
pub fn with_version(self, version: impl Into<String>) -> Self
Set the CRDT library version.
Sourcepub fn with_sync_version(self, version: u64) -> Self
pub fn with_sync_version(self, version: u64) -> Self
Set the sync version.
Sourcepub fn mark_synced(&mut self)
pub fn mark_synced(&mut self)
Update the last sync timestamp to now.
Sourcepub fn remove_peer(&mut self, peer_id: &str)
pub fn remove_peer(&mut self, peer_id: &str)
Remove a peer by ID.
Sourcepub fn active_peers(&self, within: Duration) -> Vec<&Peer>
pub fn active_peers(&self, within: Duration) -> Vec<&Peer>
Get active peers (seen within the given duration).
Trait Implementations§
Source§impl<'de> Deserialize<'de> for SyncState
impl<'de> Deserialize<'de> for SyncState
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl StructuralPartialEq for SyncState
Auto Trait Implementations§
impl Freeze for SyncState
impl RefUnwindSafe for SyncState
impl Send for SyncState
impl Sync for SyncState
impl Unpin for SyncState
impl UnsafeUnpin for SyncState
impl UnwindSafe for SyncState
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