pub struct SyncManager<T: NetworkTransport> { /* private fields */ }Expand description
Manages synchronization between peers.
Implementations§
Source§impl<T: NetworkTransport> SyncManager<T>
impl<T: NetworkTransport> SyncManager<T>
Sourcepub fn new(transport: Arc<T>, config: SyncConfig) -> Self
pub fn new(transport: Arc<T>, config: SyncConfig) -> Self
Create a new sync manager for a transport and configuration.
Sourcepub fn config(&self) -> &SyncConfig
pub fn config(&self) -> &SyncConfig
Return the active synchronization configuration.
Sourcepub async fn broadcast_update(
&mut self,
document_id: &str,
delta: Vec<u8>,
version: u64,
) -> Result<(), SdkError>
pub async fn broadcast_update( &mut self, document_id: &str, delta: Vec<u8>, version: u64, ) -> Result<(), SdkError>
Broadcast a document update to all connected peers.
§Errors
Returns SdkError::SyncError if the transport broadcast fails.
Sourcepub async fn request_sync(
&mut self,
peer_id: &PeerId,
document_id: &str,
version: u64,
) -> Result<(), SdkError>
pub async fn request_sync( &mut self, peer_id: &PeerId, document_id: &str, version: u64, ) -> Result<(), SdkError>
Send a sync request to a specific peer.
§Errors
Returns SdkError::SyncError if sending the request fails.
Sourcepub fn update_peer_state(
&mut self,
peer_id: &PeerId,
document_id: &str,
version: u64,
)
pub fn update_peer_state( &mut self, peer_id: &PeerId, document_id: &str, version: u64, )
Update local sync metadata for a peer/document pair.
Sourcepub fn get_peer_state(&self, peer_id: &PeerId) -> Option<&PeerSyncState>
pub fn get_peer_state(&self, peer_id: &PeerId) -> Option<&PeerSyncState>
Return sync metadata for a peer if present.
Auto Trait Implementations§
impl<T> Freeze for SyncManager<T>
impl<T> RefUnwindSafe for SyncManager<T>where
T: RefUnwindSafe,
impl<T> Send for SyncManager<T>
impl<T> Sync for SyncManager<T>
impl<T> Unpin for SyncManager<T>
impl<T> UnsafeUnpin for SyncManager<T>
impl<T> UnwindSafe for SyncManager<T>where
T: RefUnwindSafe,
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