pub struct NegentropySync { /* private fields */ }Expand description
Manager for Negentropy-based document sync
Provides efficient O(log n) set reconciliation to discover which documents need to be synced, avoiding unbounded Automerge sync state.
Implementations§
Source§impl NegentropySync
impl NegentropySync
Sourcepub fn new() -> NegentropySync
pub fn new() -> NegentropySync
Create a new NegentropySync manager
Sourcepub fn initiate_sync(
&self,
peer_id: PublicKey,
local_items: Vec<SyncItem>,
) -> Result<Vec<u8>, Error>
pub fn initiate_sync( &self, peer_id: PublicKey, local_items: Vec<SyncItem>, ) -> Result<Vec<u8>, Error>
Start a sync session with a peer as initiator
Returns the initial message to send to the peer.
Sourcepub fn handle_message(
&self,
peer_id: PublicKey,
message: &[u8],
local_items: Vec<SyncItem>,
) -> Result<ReconcileResult, Error>
pub fn handle_message( &self, peer_id: PublicKey, message: &[u8], local_items: Vec<SyncItem>, ) -> Result<ReconcileResult, Error>
Handle incoming sync message from peer
If we have an active session, this is a response to our initiation. Otherwise, we’re the responder and should create a new session.
Sourcepub fn stats(&self) -> NegentropyStats
pub fn stats(&self) -> NegentropyStats
Get current statistics
Sourcepub fn has_session(&self, peer_id: &PublicKey) -> bool
pub fn has_session(&self, peer_id: &PublicKey) -> bool
Check if there’s an active session with a peer
Sourcepub fn cancel_session(&self, peer_id: &PublicKey)
pub fn cancel_session(&self, peer_id: &PublicKey)
Cancel a sync session
Trait Implementations§
Source§impl Default for NegentropySync
impl Default for NegentropySync
Source§fn default() -> NegentropySync
fn default() -> NegentropySync
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for NegentropySync
impl RefUnwindSafe for NegentropySync
impl Send for NegentropySync
impl Sync for NegentropySync
impl Unpin for NegentropySync
impl UnsafeUnpin for NegentropySync
impl UnwindSafe for NegentropySync
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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>
Converts
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>
Converts
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