pub struct Stamp {
pub id: Id,
pub event: Event,
}Expand description
An ITC stamp: a pair of (ID tree, Event tree).
The stamp is the fundamental unit of causality tracking in ITC. Each agent holds a stamp; operations like fork, join, and event modify the stamp to track causal history.
Fields§
§id: IdThe identity partition owned by this stamp.
event: EventThe causal history recorded by this stamp.
Implementations§
Source§impl Stamp
impl Stamp
Sourcepub const fn new(id: Id, event: Event) -> Self
pub const fn new(id: Id, event: Event) -> Self
Create a new stamp with the given ID and event trees.
Sourcepub const fn seed() -> Self
pub const fn seed() -> Self
Create the initial seed stamp: owns the full interval with zero events.
This is the starting point for an ITC system. The seed stamp owns the entire [0, 1) interval and has recorded no events.
Sourcepub const fn anonymous() -> Self
pub const fn anonymous() -> Self
Create an anonymous stamp: owns nothing, zero events.
An anonymous stamp cannot record events but can receive causality information through join operations.
Sourcepub fn is_anonymous(&self) -> bool
pub fn is_anonymous(&self) -> bool
Returns true if this stamp owns no interval.
Source§impl Stamp
impl Stamp
Sourcepub fn fork(&self) -> (Self, Self)
pub fn fork(&self) -> (Self, Self)
Split this stamp’s ID interval into two halves.
Used when a new agent forks from an existing one.
Returns (left, right) where left and right partition
the original interval: left ∪ right = original, left ∩ right = ∅.
Both stamps share the same event tree (causal history at time of fork).
§Panics
Panics if this stamp is anonymous (owns no interval to split).
Sourcepub fn join(a: &Self, b: &Self) -> Self
pub fn join(a: &Self, b: &Self) -> Self
Merge two stamps into one, combining their ID intervals and taking the pointwise maximum of their event trees.
Used when an agent retires and donates its interval back, or when synchronizing causality information between agents.
Sourcepub fn event(&mut self)
pub fn event(&mut self)
Record a new event, inflating the event tree.
Called on every event emission. The event counter is monotonically increased at a position owned by this stamp’s ID. Uses the fill-then-grow strategy from the ITC paper for minimal tree growth.
§Panics
Panics if this stamp is anonymous (cannot record events without owning part of the interval).
Sourcepub fn leq(&self, other: &Self) -> bool
pub fn leq(&self, other: &Self) -> bool
Causal dominance: returns true if self happened-before-or-equal other.
This means every event recorded by self is also recorded by other.
Sourcepub fn concurrent(&self, other: &Self) -> bool
pub fn concurrent(&self, other: &Self) -> bool
Returns true if neither stamp causally dominates the other.
Two stamps are concurrent if there exist events in each that the other has not observed.
Source§impl Stamp
impl Stamp
Sourcepub fn serialize_compact(&self) -> Vec<u8> ⓘ
pub fn serialize_compact(&self) -> Vec<u8> ⓘ
Serialize this stamp using the compact binary ITC format.
Sourcepub fn deserialize_compact(input: &[u8]) -> Result<Self, CodecError>
pub fn deserialize_compact(input: &[u8]) -> Result<Self, CodecError>
Deserialize a stamp from the compact binary ITC format.
§Errors
Returns CodecError when the input is malformed, truncated,
has an unknown format version, or contains trailing data.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Stamp
impl<'de> Deserialize<'de> for Stamp
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for Stamp
impl StructuralPartialEq for Stamp
Auto Trait Implementations§
impl Freeze for Stamp
impl RefUnwindSafe for Stamp
impl Send for Stamp
impl Sync for Stamp
impl Unpin for Stamp
impl UnsafeUnpin for Stamp
impl UnwindSafe for Stamp
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§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.