Enum DocumentMutation
pub enum DocumentMutation {
Snapshot(Vec<u8>),
Incremental(Vec<u8>),
}Expand description
Meaning of a signed document payload. Keeping this tag inside
[SignedOp::payload] makes snapshot-vs-incremental part of the bytes the
device signs without changing the persisted SignedOp layout.
Variants§
Snapshot(Vec<u8>)
A complete Automerge document used to seed a late joiner.
Incremental(Vec<u8>)
One Automerge incremental change set.
Implementations§
§impl DocumentMutation
impl DocumentMutation
pub fn kind(&self) -> DocumentMutationKind
pub fn kind(&self) -> DocumentMutationKind
Kind of this mutation independent of its bytes.
pub fn encode_frames(&self) -> Result<Vec<Vec<u8>>, DocumentMutationEncodeError>
pub fn encode_frames(&self) -> Result<Vec<Vec<u8>>, DocumentMutationEncodeError>
Encode this mutation as the signed payloads that carry it: one frame
when it fits in [DOCUMENT_SEGMENT_BYTES], otherwise one frame per
segment. Each returned payload must be signed as its own envelope and
the envelopes sent in order.
§Errors
Returns [DocumentMutationEncodeError::TooLarge] when the Automerge
bytes exceed [MAX_DOCUMENT_TRANSFER_BYTES].
§impl DocumentMutation
impl DocumentMutation
pub fn visit_snapshot_encoding(
bytes: &[u8],
write: impl FnMut(&[u8]),
) -> Result<(), DocumentMutationEncodeError>
pub fn visit_snapshot_encoding( bytes: &[u8], write: impl FnMut(&[u8]), ) -> Result<(), DocumentMutationEncodeError>
Visit the exact snapshot encoding without allocating a payload buffer. The visitor owns any destination allocation or digest state.
§Errors
Returns [DocumentMutationEncodeError::TooLarge] when bytes exceed
[MAX_DOCUMENT_MUTATION_BYTES].
pub fn encode(&self) -> Result<Vec<u8>, DocumentMutationEncodeError>
pub fn encode(&self) -> Result<Vec<u8>, DocumentMutationEncodeError>
Encode the kind and Automerge bytes into the payload carried by one
[SignedOp]. Use Self::encode_frames for mutations that may
exceed a single frame.
§Errors
Returns [DocumentMutationEncodeError::TooLarge] when the Automerge
bytes exceed [MAX_DOCUMENT_MUTATION_BYTES].
pub fn decode(payload: &[u8]) -> Result<DocumentMutation, DocumentMutationError>
pub fn decode(payload: &[u8]) -> Result<DocumentMutation, DocumentMutationError>
Decode a complete versioned document mutation, either a single frame
or a payload reassembled from segments. Unprefixed payloads fail
explicitly rather than being guessed to be an incremental update.
Wire frames are checked with the tighter
[crate::document_transfer::DocumentFrame::decode].
§Errors
Returns [DocumentMutationError::MissingPrefix] for unprefixed bytes,
[DocumentMutationError::Segmented] for one segment of a larger
mutation, or [DocumentMutationError::UnknownKind] /
[DocumentMutationError::Truncated] for a corrupt typed body.
Trait Implementations§
§impl Clone for DocumentMutation
impl Clone for DocumentMutation
§fn clone(&self) -> DocumentMutation
fn clone(&self) -> DocumentMutation
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more§impl Debug for DocumentMutation
impl Debug for DocumentMutation
§impl<'de> Deserialize<'de> for DocumentMutation
impl<'de> Deserialize<'de> for DocumentMutation
§fn deserialize<__D>(
__deserializer: __D,
) -> Result<DocumentMutation, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<DocumentMutation, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
§impl PartialEq for DocumentMutation
impl PartialEq for DocumentMutation
§fn eq(&self, other: &DocumentMutation) -> bool
fn eq(&self, other: &DocumentMutation) -> bool
self and other values to be equal, and is used by ==.§impl Serialize for DocumentMutation
impl Serialize for DocumentMutation
§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 Eq for DocumentMutation
impl StructuralPartialEq for DocumentMutation
Auto Trait Implementations§
impl Freeze for DocumentMutation
impl RefUnwindSafe for DocumentMutation
impl Send for DocumentMutation
impl Sync for DocumentMutation
impl Unpin for DocumentMutation
impl UnsafeUnpin for DocumentMutation
impl UnwindSafe for DocumentMutation
Blanket Implementations§
§impl<T> AnyEq for T
impl<T> AnyEq for T
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,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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