pub struct OrSet<T: Ord, K: Ord> { /* private fields */ }Expand description
Observed-remove set with add-wins semantics.
Lean model: Crdt.ORSet.State α τ = Finset (α × τ) × Finset τ.
Implementations§
Source§impl<T: Ord, K: Ord> OrSet<T, K>
impl<T: Ord, K: Ord> OrSet<T, K>
pub fn new() -> Self
pub fn add(&mut self, element: T, token: K)
pub fn apply_remove<I>(&mut self, tokens: I)where
I: IntoIterator<Item = K>,
pub fn merge(&mut self, other: &Self)where
T: Clone,
K: Clone,
pub fn adds(&self) -> &BTreeSet<(T, K)>
pub fn tombstones(&self) -> &BTreeSet<K>
Trait Implementations§
Source§impl<T: Ord + Clone, K: Ord + Clone> Crdt for OrSet<T, K>
impl<T: Ord + Clone, K: Ord + Clone> Crdt for OrSet<T, K>
Source§fn validate_record(
&self,
id: RecordId,
delta: &Self::Delta,
) -> Result<(), WireError>
fn validate_record( &self, id: RecordId, delta: &Self::Delta, ) -> Result<(), WireError>
Refuses sequence-0 adds and removes with WireError::ZeroSequenceAdd
and WireError::ZeroSequenceRemove. RecordKernel.permitted requires
a positive sequence for every payload. Adds also mint a token at their
record ID; allocateToken requires a positive sequence. These checks
need no writer count, so the raw carrier applies them too. The author
bound and add token value stay with the checked writers.
Every positive-sequence record is accepted. An add joins the add set, even
when its token is already tombstoned (that is the observed-remove rule,
and a fresh set applies it). A remove tombstones every token it names
whether or not this replica observed them (RecordKernel.payloadOwned .remove), so a fresh set applies it too. A remove naming no tokens is the
lattice bottom: the local writer emits it for an absent element, and
joining ⊥ on any carrier is the correct application of that record,
not a dropped one.
type Delta = OrSetDelta<T, K>
fn apply_delta(&mut self, delta: Self::Delta)
Source§fn replica_count(&self) -> Option<usize>
fn replica_count(&self) -> Option<usize>
None for CRDTs without a fixed arity.Source§impl<T: Ord + Clone, K: Ord + Clone> Mergeable for OrSet<T, K>
impl<T: Ord + Clone, K: Ord + Clone> Mergeable for OrSet<T, K>
Source§fn merge(&mut self, other: &Self) -> Result<(), MergeError>
fn merge(&mut self, other: &Self) -> Result<(), MergeError>
Source§impl WireDecode for OrSet<String, u64>
impl WireDecode for OrSet<String, u64>
fn decode_wire(cursor: &mut WireCursor<'_>) -> Result<Self, WireError>
Source§fn decode_wire_with_collection_limits(
cursor: &mut WireCursor<'_>,
limits: CollectionLimits,
) -> Result<Self, WireError>
fn decode_wire_with_collection_limits( cursor: &mut WireCursor<'_>, limits: CollectionLimits, ) -> Result<Self, WireError>
Source§fn decode_wire_with_limits(
cursor: &mut WireCursor<'_>,
collections: CollectionLimits,
_max_records: Option<usize>,
) -> Result<Self, WireError>
fn decode_wire_with_limits( cursor: &mut WireCursor<'_>, collections: CollectionLimits, _max_records: Option<usize>, ) -> Result<Self, WireError>
Source§fn from_wire_bytes_with_collection_limits(
bytes: &[u8],
limits: CollectionLimits,
) -> Result<Self, WireError>
fn from_wire_bytes_with_collection_limits( bytes: &[u8], limits: CollectionLimits, ) -> Result<Self, WireError>
fn from_wire_bytes(bytes: &[u8]) -> Result<Self, WireError>
Source§impl WireDecode for OrSet<u64, u64>
impl WireDecode for OrSet<u64, u64>
fn decode_wire(cursor: &mut WireCursor<'_>) -> Result<Self, WireError>
Source§fn decode_wire_with_collection_limits(
cursor: &mut WireCursor<'_>,
limits: CollectionLimits,
) -> Result<Self, WireError>
fn decode_wire_with_collection_limits( cursor: &mut WireCursor<'_>, limits: CollectionLimits, ) -> Result<Self, WireError>
Source§fn decode_wire_with_limits(
cursor: &mut WireCursor<'_>,
collections: CollectionLimits,
_max_records: Option<usize>,
) -> Result<Self, WireError>
fn decode_wire_with_limits( cursor: &mut WireCursor<'_>, collections: CollectionLimits, _max_records: Option<usize>, ) -> Result<Self, WireError>
Source§fn from_wire_bytes_with_collection_limits(
bytes: &[u8],
limits: CollectionLimits,
) -> Result<Self, WireError>
fn from_wire_bytes_with_collection_limits( bytes: &[u8], limits: CollectionLimits, ) -> Result<Self, WireError>
fn from_wire_bytes(bytes: &[u8]) -> Result<Self, WireError>
Source§impl WireEncode for OrSet<String, u64>
impl WireEncode for OrSet<String, u64>
fn encode_wire(&self, out: &mut Vec<u8>) -> Result<(), WireError>
fn to_wire_bytes(&self) -> Result<Vec<u8>, WireError>
Source§impl WireEncode for OrSet<u64, u64>
impl WireEncode for OrSet<u64, u64>
fn encode_wire(&self, out: &mut Vec<u8>) -> Result<(), WireError>
fn to_wire_bytes(&self) -> Result<Vec<u8>, WireError>
Source§impl WireSchema for OrSet<String, u64>
impl WireSchema for OrSet<String, u64>
const REQUIRES_ARITY: bool = false
Source§fn wire_schema() -> Cow<'static, [u8]>
fn wire_schema() -> Cow<'static, [u8]>
Source§impl WireSchema for OrSet<u64, u64>
impl WireSchema for OrSet<u64, u64>
const REQUIRES_ARITY: bool = false
Source§fn wire_schema() -> Cow<'static, [u8]>
fn wire_schema() -> Cow<'static, [u8]>
impl<T: Eq + Ord, K: Eq + Ord> Eq for OrSet<T, K>
impl<T: Ord, K: Ord> StructuralPartialEq for OrSet<T, K>
Auto Trait Implementations§
impl<T, K> Freeze for OrSet<T, K>
impl<T, K> RefUnwindSafe for OrSet<T, K>where
K: RefUnwindSafe,
T: RefUnwindSafe,
impl<T, K> Send for OrSet<T, K>where
K: Send,
T: Send,
impl<T, K> Sync for OrSet<T, K>where
K: Sync,
T: Sync,
impl<T, K> Unpin for OrSet<T, K>
impl<T, K> UnsafeUnpin for OrSet<T, K>
impl<T, K> UnwindSafe for OrSet<T, K>where
K: RefUnwindSafe,
T: RefUnwindSafe,
Blanket Implementations§
Source§impl<T> Any for Twhere
T: 'static + ?Sized,
impl<T> Any for Twhere
T: 'static + ?Sized,
Source§fn type_id(&self) -> TypeId
fn type_id(&self) -> TypeId
TypeId of self. Read moreSource§impl<T> Borrow<T> for Twhere
T: ?Sized,
impl<T> Borrow<T> for Twhere
T: ?Sized,
Source§fn borrow(&self) -> &T
fn borrow(&self) -> &T
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§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
clone_to_uninit)self to dest. Read moreSource§impl<T, U> Into<U> for Twhere
U: From<T>,
impl<T, U> Into<U> for Twhere
U: From<T>,
Source§fn into(self) -> U
fn into(self) -> U
Calls U::from(self).
That is, this conversion is whatever the implementation of
From<T> for U chooses to do.