pub struct SyncTracker { /* private fields */ }sync only.Expand description
Sync tracker state (each endpoint maintains this)
Tracks version numbers for synchronization:
current_num: Version of current local statelast_sent_num: Version of last state we sent to peerlast_acked: Highest version our peer acknowledged receivingpeer_state_num: Highest version we’ve received from peer
Implementations§
Source§impl SyncTracker
impl SyncTracker
Sourcepub fn with_initial_version(version: u64) -> Self
pub fn with_initial_version(version: u64) -> Self
Create a tracker with initial state
Sourcepub fn current_version(&self) -> u64
pub fn current_version(&self) -> u64
Get current local state version
Sourcepub fn last_sent_version(&self) -> u64
pub fn last_sent_version(&self) -> u64
Get last sent version
Sourcepub fn last_acked_version(&self) -> u64
pub fn last_acked_version(&self) -> u64
Get highest version acked by peer
Sourcepub fn peer_version(&self) -> u64
pub fn peer_version(&self) -> u64
Get highest version received from peer
Sourcepub fn has_pending_updates(&self) -> bool
pub fn has_pending_updates(&self) -> bool
Check if we have pending updates to send
Sourcepub fn is_synchronized(&self) -> bool
pub fn is_synchronized(&self) -> bool
Check if the state is in sync with peer
Sourcepub fn bump_version(&mut self) -> u64
pub fn bump_version(&mut self) -> u64
Bump local state version (call when local state changes)
Sourcepub fn record_sent(&mut self, sent_version: u64)
pub fn record_sent(&mut self, sent_version: u64)
Record that we sent a message
Returns the version number that was marked as sent.
Sourcepub fn process_incoming(&mut self, msg: &SyncMessage) -> bool
pub fn process_incoming(&mut self, msg: &SyncMessage) -> bool
Process an incoming sync message
Updates:
peer_state_numfrom the sender’s current versionlast_ackedfrom the sender’s ack field
Returns true if the message contained new state (not just an ack).
Sourcepub fn create_message(&self, diff: Vec<u8>, base_state_num: u64) -> SyncMessage
pub fn create_message(&self, diff: Vec<u8>, base_state_num: u64) -> SyncMessage
Create a sync message with current state info
The caller should fill in the diff payload.
Sourcepub fn create_ack(&self) -> SyncMessage
pub fn create_ack(&self) -> SyncMessage
Create an ack-only message
Sourcepub fn diff_base_version(&self) -> u64
pub fn diff_base_version(&self) -> u64
Get the base state number that should be used for diff computation
This is the last version we know the peer has acknowledged.
Trait Implementations§
Source§impl Clone for SyncTracker
impl Clone for SyncTracker
Source§fn clone(&self) -> SyncTracker
fn clone(&self) -> SyncTracker
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more