pub struct CausalContext {
pub parent_id: Option<MessageId>,
pub vector_clock_entry: Option<u64>,
}Expand description
Causal metadata carried inside a protocol message envelope.
Fields§
§parent_id: Option<MessageId>Optional reference to the causally preceding message.
vector_clock_entry: Option<u64>Optional logical timestamp for this message’s causal-chain position.
Implementations§
Source§impl CausalContext
impl CausalContext
Sourcepub const fn independent() -> Self
pub const fn independent() -> Self
Create a causally independent context with no parent or vector-clock entry.
Sourcepub const fn with_parent(parent_id: MessageId) -> Self
pub const fn with_parent(parent_id: MessageId) -> Self
Create a context that follows parent_id in a causal chain.
Sourcepub fn encoded_len(&self) -> Result<usize, ProtocolError>
pub fn encoded_len(&self) -> Result<usize, ProtocolError>
Return the number of bytes needed for deterministic causal-context encoding.
§Errors
Returns ProtocolError::CodecError when the message id length cannot fit
in the protocol’s u32 length field or the total length overflows usize.
Sourcepub fn serialize(&self) -> Result<Vec<u8>, ProtocolError>
pub fn serialize(&self) -> Result<Vec<u8>, ProtocolError>
Serialize this causal context with deterministic big-endian field encoding.
§Errors
Returns ProtocolError::CodecError when a length field cannot represent
the encoded context.
Sourcepub fn to_wire_bytes(&self) -> Result<Vec<u8>, ProtocolError>
pub fn to_wire_bytes(&self) -> Result<Vec<u8>, ProtocolError>
Serialize this causal context for wire transport.
§Errors
Returns ProtocolError::CodecError when a length field cannot represent
the encoded context.
Sourcepub fn deserialize(bytes: &[u8]) -> Result<Self, ProtocolError>
pub fn deserialize(bytes: &[u8]) -> Result<Self, ProtocolError>
Deserialize a causal context from deterministic wire bytes.
§Errors
Returns ProtocolError::CodecError when the bytes are truncated, contain
invalid presence tags, contain invalid UTF-8 message ids, or contain
trailing bytes.
Sourcepub fn from_wire_bytes(bytes: &[u8]) -> Result<Self, ProtocolError>
pub fn from_wire_bytes(bytes: &[u8]) -> Result<Self, ProtocolError>
Deserialize a causal context from deterministic wire bytes.
§Errors
Returns ProtocolError::CodecError when the bytes are truncated, contain
invalid presence tags, contain invalid UTF-8 message ids, or contain
trailing bytes.
Trait Implementations§
Source§impl Clone for CausalContext
impl Clone for CausalContext
Source§fn clone(&self) -> CausalContext
fn clone(&self) -> CausalContext
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for CausalContext
impl Debug for CausalContext
Source§impl Default for CausalContext
impl Default for CausalContext
impl Eq for CausalContext
Source§impl PartialEq for CausalContext
impl PartialEq for CausalContext
Source§fn eq(&self, other: &CausalContext) -> bool
fn eq(&self, other: &CausalContext) -> bool
self and other values to be equal, and is used by ==.impl StructuralPartialEq for CausalContext
Auto Trait Implementations§
impl Freeze for CausalContext
impl RefUnwindSafe for CausalContext
impl Send for CausalContext
impl Sync for CausalContext
impl Unpin for CausalContext
impl UnsafeUnpin for CausalContext
impl UnwindSafe for CausalContext
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.