Skip to main content

SyncManager

Struct SyncManager 

Source
pub struct SyncManager<T: NetworkTransport> { /* private fields */ }
Expand description

Manages synchronization between peers.

Implementations§

Source§

impl<T: NetworkTransport> SyncManager<T>

Source

pub fn new(transport: Arc<T>, config: SyncConfig) -> Self

Create a new sync manager for a transport and configuration.

Source

pub fn config(&self) -> &SyncConfig

Return the active synchronization configuration.

Source

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.

Source

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.

Source

pub fn update_peer_state( &mut self, peer_id: &PeerId, document_id: &str, version: u64, )

Update local sync metadata for a peer/document pair.

Source

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V