pub struct CausalLink {
pub origin_hash: u64,
pub horizon_encoded: u64,
pub sequence: u64,
pub parent_hash: u64,
}Expand description
Causal link — 32 bytes prepended to each event in causal-framed EventFrames.
Wire format (32 bytes, no padding):
origin_hash: 8 bytes (u64) — entity identity
horizon_encoded: 8 bytes (u64) — compressed observed horizon
sequence: 8 bytes (u64) — monotonic per-entity
parent_hash: 8 bytes (u64) — xxh3 of (prev link ++ prev payload)Fields are ordered with the smallest first; serialization uses
explicit to_bytes/from_bytes, not transmute, so any in-memory
padding the compiler chooses doesn’t leak to the wire.
Fields§
§origin_hash: u64Entity identity. The low 32 bits match
NetHeader::origin_hash (still u32 on the per-packet
wire); the full u64 is used for chain integrity and
cross-channel accounting where the wider tag avoids the
~65k peer birthday-collision floor a u32 truncation
would produce.
horizon_encoded: u64Compressed observed horizon (64-bit bloom sketch).
Approximate, with documented FPR-vs-cardinality table on
HorizonEncoder — see state/horizon.rs. Tuned for
≲ 16 active origins per event; callers needing exact
horizons at higher cardinalities must fall back to the
out-of-band full-ObservedHorizon path
(ObservedHorizon::has_observed).
sequence: u64Monotonic sequence number from entity’s reference frame.
parent_hash: u64xxh3 hash of the previous event’s (CausalLink bytes ++ payload bytes).
Implementations§
Source§impl CausalLink
impl CausalLink
Sourcepub fn genesis(origin_hash: u64, horizon_encoded: u64) -> CausalLink
pub fn genesis(origin_hash: u64, horizon_encoded: u64) -> CausalLink
Create the genesis link for a new entity (no parent).
Sourcepub fn next(&self, payload: &[u8], horizon_encoded: u64) -> Option<CausalLink>
pub fn next(&self, payload: &[u8], horizon_encoded: u64) -> Option<CausalLink>
Create the next link in a chain given the previous link and payload.
Returns None if the sequence number would overflow u64::MAX.
Sourcepub fn from_bytes(data: &[u8]) -> Option<CausalLink>
pub fn from_bytes(data: &[u8]) -> Option<CausalLink>
Deserialize from bytes. Returns None if too short.
Sourcepub fn is_genesis(&self) -> bool
pub fn is_genesis(&self) -> bool
Check if this is a genesis link (sequence 0, no parent).
Trait Implementations§
Source§impl Clone for CausalLink
impl Clone for CausalLink
Source§fn clone(&self) -> CausalLink
fn clone(&self) -> CausalLink
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for CausalLink
Source§impl Debug for CausalLink
impl Debug for CausalLink
impl Eq for CausalLink
Source§impl PartialEq for CausalLink
impl PartialEq for CausalLink
Source§fn eq(&self, other: &CausalLink) -> bool
fn eq(&self, other: &CausalLink) -> bool
self and other values to be equal, and is used by ==.impl StructuralPartialEq for CausalLink
Auto Trait Implementations§
impl Freeze for CausalLink
impl RefUnwindSafe for CausalLink
impl Send for CausalLink
impl Sync for CausalLink
impl Unpin for CausalLink
impl UnsafeUnpin for CausalLink
impl UnwindSafe for CausalLink
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<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.