pub struct Message {
pub heads: Vec<ChangeHash>,
pub need: Vec<ChangeHash>,
pub have: Vec<Have>,
pub changes: ChunkList,
pub supported_capabilities: Option<Vec<Capability>>,
pub version: MessageVersion,
}Expand description
The sync message to be sent.
§Notes about encoding
There are two versions of the sync message, V1 and V2. The V1 message is the original message which automerge shipped with and V2 is an extension which allows for encoding the changes as either a list of changes or as a compressed document format. This makes syncing up for the first time faster.
Encoding this in a backwards compatible way is a bit tricky. The wire format of the v1 message
didn’t allow for any forwards compatible changes. In order to accomodate this the first message
a peer sends is a V1 message with a length previxed Vec<Capability> appended to it. For old
implementations this appended data is just ignored but new implementations read it and store
the advertised capabilities on the sync state. This allows new implementations to discover if
the remote peer supports the V2 message format (the Capability::MessageV2 capability) and if
so send a V2 message.
Fields§
§heads: Vec<ChangeHash>The heads of the sender.
need: Vec<ChangeHash>The hashes of any changes that are being explicitly requested from the recipient.
have: Vec<Have>A summary of the changes that the sender already has.
changes: ChunkListThe changes for the recipient to apply.
This is a Vec of bytes which should be passed to Automerge::load_incremental. The reason
it is a Vec<Vec<u8>> and not a Vec<u8> is that the V1 message format is a sequence of
change chunks, each of which is length delimited. The V2 message format is a single length
delimited chunk but we nest it inside a Vec for backwards compatibility.
supported_capabilities: Option<Vec<Capability>>The capabilities the sender supports
version: MessageVersionWhat version to encode this message as
Implementations§
Trait Implementations§
Source§impl Serialize for Message
impl Serialize for Message
Source§fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
impl StructuralPartialEq for Message
Auto Trait Implementations§
impl Freeze for Message
impl RefUnwindSafe for Message
impl Send for Message
impl Sync for Message
impl Unpin for Message
impl UnwindSafe for Message
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
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>
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