pub struct CausalContext {
pub parent: Option<MessageId>,
pub parent_chain: Vec<MessageId>,
}Expand description
Causal metadata used to relate a message to an optional parent message.
Fields§
§parent: Option<MessageId>Parent message that must causally precede this message, if any.
parent_chain: Vec<MessageId>Full causal parent chain ordered as parent, grandparent, and so on.
Implementations§
Source§impl CausalContext
impl CausalContext
Sourcepub fn child_of(parent: MessageId) -> Self
pub fn child_of(parent: MessageId) -> Self
Creates a context for a message that directly follows parent, with a
depth-1 chain (parent_chain == [parent]).
WARNING: this records ONLY the immediate parent, so
happened_before will not see parent’s own
ancestors. Use this only when parent is a chain root (no ancestors of
its own). When the parent itself has a causal context, build the child
with child_of_context so transitive
happens-before is preserved — otherwise causal ordering is silently
truncated to one hop.
Sourcepub fn child_of_context(parent: MessageId, parent_context: &Self) -> Self
pub fn child_of_context(parent: MessageId, parent_context: &Self) -> Self
Creates a child context by prepending parent to the parent’s own causal chain.
Sourcepub fn from_parent_chain(parent_chain: Vec<MessageId>) -> Self
pub fn from_parent_chain(parent_chain: Vec<MessageId>) -> Self
Creates a context from an explicit parent chain ordered parent to oldest ancestor.
Sourcepub fn parent_chain(&self) -> &[MessageId]
pub fn parent_chain(&self) -> &[MessageId]
Returns the full parent chain ordered parent to oldest ancestor.
Sourcepub fn happened_before(&self, ancestor_id: MessageId) -> bool
pub fn happened_before(&self, ancestor_id: MessageId) -> bool
Returns whether ancestor_id causally happened before this context’s message.
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.