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§
sourcefn generate_sync_message(&self, sync_state: &mut State) -> Option<Message>
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.
sourcefn receive_sync_message(
&mut self,
sync_state: &mut State,
message: Message,
) -> Result<(), AutomergeError>
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