pub enum CrdtValue {
Set(ORSet<CrdtScalar>),
SetRemoveWins(ORSet<CrdtScalar, RemoveWins>),
Seq(RGA<CrdtScalar>),
Register(MVRegister<CrdtScalar>),
}Expand description
A live CRDT held by the interpreter. Wraps the actual logicaffeine_data type, so its
convergence behaviour is identical to the compiled tier’s by construction.
Variants§
Set(ORSet<CrdtScalar>)
SharedSet of T / SharedSet (AddWins) — observed-remove set, add-wins on a
concurrent add/remove of the same element.
SetRemoveWins(ORSet<CrdtScalar, RemoveWins>)
SharedSet (RemoveWins) — observed-remove set, remove-wins on a concurrent
add/remove (e.g. an access-revocation / block list).
Seq(RGA<CrdtScalar>)
SharedSequence of T — replicated growable array (RGA). Stable, convergent
insertion order.
Register(MVRegister<CrdtScalar>)
Divergent T — multi-value register (MVRegister). Keeps concurrent writes until
one is resolved.
Implementations§
Source§impl CrdtValue
impl CrdtValue
pub fn new_set(replica: ReplicaId) -> CrdtValue
pub fn new_set_remove_wins(replica: ReplicaId) -> CrdtValue
pub fn new_seq(replica: ReplicaId) -> CrdtValue
pub fn new_register(replica: ReplicaId) -> CrdtValue
Sourcepub fn insert(&mut self, value: &RuntimeValue) -> Result<(), String>
pub fn insert(&mut self, value: &RuntimeValue) -> Result<(), String>
Add element to <set> — insert into the observed-remove set.
Sourcepub fn remove(&mut self, value: &RuntimeValue) -> Result<(), String>
pub fn remove(&mut self, value: &RuntimeValue) -> Result<(), String>
Remove element from <set> — observed-remove deletion.
Sourcepub fn contains(&self, value: &RuntimeValue) -> Result<bool, String>
pub fn contains(&self, value: &RuntimeValue) -> Result<bool, String>
<set> contains element — observed-remove membership.
Sourcepub fn append(&mut self, value: &RuntimeValue) -> Result<(), String>
pub fn append(&mut self, value: &RuntimeValue) -> Result<(), String>
Append element to <sequence> — RGA append at the end.
Sourcepub fn resolve(&mut self, value: &RuntimeValue) -> Result<(), String>
pub fn resolve(&mut self, value: &RuntimeValue) -> Result<(), String>
Set <register> to value / Resolve <register> to value — the divergent register
takes a value that dominates all concurrent ones.
Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
length of <collection> — element count (set cardinality or sequence length).
pub fn is_empty(&self) -> bool
Sourcepub fn to_runtime_vec(&self) -> Vec<RuntimeValue>
pub fn to_runtime_vec(&self) -> Vec<RuntimeValue>
The elements as runtime values, in convergent order for a sequence and sorted for a set (sets have no intrinsic order — sorting makes the rendering deterministic).
Sourcepub fn register_value(&self) -> Option<RuntimeValue>
pub fn register_value(&self) -> Option<RuntimeValue>
The resolved value of a register — the single current value, or None while it is
empty or still divergent (multiple concurrent values).
Sourcepub fn merge(&mut self, other: &CrdtValue) -> Result<(), String>
pub fn merge(&mut self, other: &CrdtValue) -> Result<(), String>
Merge another CRDT of the SAME kind into this one (the convergent join). Mismatched kinds are a type error rather than a silent no-op.
Sourcepub fn version(&self) -> VClock
pub fn version(&self) -> VClock
The current causal version (vector clock) — every update this replica has observed. The
δ-CRDT mergeable send remembers the version it last shipped to a peer and ships only the
delta SINCE that version, so a large set/sequence syncs its few NEW entries, not its whole
state. Idempotent + commutative, so reordering or redelivering deltas still converges.
Sourcepub fn delta_since_bytes(&self, since: &VClock) -> Option<Vec<u8>>
pub fn delta_since_bytes(&self, since: &VClock) -> Option<Vec<u8>>
Serialize the changes since since as a KIND-TAGGED delta payload — far smaller than the
full state when little changed. None if the variant can’t produce a delta (history
truncated); the caller falls back to the full-state crdt_to_wire.
Sourcepub fn apply_delta_bytes(&mut self, bytes: &[u8]) -> bool
pub fn apply_delta_bytes(&mut self, bytes: &[u8]) -> bool
Apply a kind-tagged delta from delta_since_bytes of the SAME kind. Returns false on a
kind mismatch or malformed bytes, leaving self unchanged — a foreign / garbage delta never
corrupts the CRDT (the network-edge safety the mergeable receive needs).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for CrdtValue
impl RefUnwindSafe for CrdtValue
impl Send for CrdtValue
impl Sync for CrdtValue
impl Unpin for CrdtValue
impl UnsafeUnpin for CrdtValue
impl UnwindSafe for CrdtValue
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,
§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.