Skip to main content

SyncDoc

Trait SyncDoc 

Source
pub trait SyncDoc {
    // Required methods
    fn generate_sync_message(&self, sync_state: &mut State) -> Option<Message>;
    fn receive_sync_message(
        &mut self,
        sync_state: &mut State,
        message: Message,
    ) -> Result<(), AutomergeError>;
    fn receive_sync_message_log_patches(
        &mut self,
        sync_state: &mut State,
        message: Message,
        patch_log: &mut PatchLog,
    ) -> Result<(), AutomergeError>;
}
Expand description

A document which can take part in the sync protocol

See the module level documentation for more details.

Required Methods§

Source

fn generate_sync_message(&self, sync_state: &mut State) -> Option<Message>

Generate a sync message for the remote peer represented by sync_state

If this returns None then there are no new messages to send, either because we are waiting for an acknolwedgement of an in-flight message, or because the remote is up to date.

  • sync_state - The State for this document and the remote peer
  • message - The Message to receive
  • patch_log - A PatchLog which will be updated with any changes that are made to the current state of the document due to the received sync message
Source

fn receive_sync_message( &mut self, sync_state: &mut State, message: Message, ) -> Result<(), AutomergeError>

Apply a received sync message to this document and sync_state

Source

fn receive_sync_message_log_patches( &mut self, sync_state: &mut State, message: Message, patch_log: &mut PatchLog, ) -> Result<(), AutomergeError>

Apply a received sync message to this document and sync_state, logging any changes that are made to patch_log

If this returns None then there are no new messages to send, either because we are waiting for an acknolwedgement of an in-flight message, or because the remote is up to date.

§Arguments
  • sync_state - The State for this document and the remote peer
  • message - The Message to receive
  • patch_log - A PatchLog which will be updated with any changes that are made to the current state of the document due to the received sync message

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§