pub struct Dag<T> { /* private fields */ }Expand description
Generic content-addressed DAG CRDT store with deterministic (lamport, OpId) topological folding.
Implementations§
Source§impl<T: Serialize> Dag<T>
impl<T: Serialize> Dag<T>
pub fn new() -> Self
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn get(&self, id: &OpId) -> Option<&DagOp<T>>
pub fn contains(&self, id: &OpId) -> bool
Sourcepub fn ops(&self) -> &BTreeMap<OpId, DagOp<T>>
pub fn ops(&self) -> &BTreeMap<OpId, DagOp<T>>
Returns all operations indexed by their content-addressed OpId.
Sourcepub fn next_lamport(&self, parents: &[OpId]) -> u64
pub fn next_lamport(&self, parents: &[OpId]) -> u64
Computes the next valid Lamport timestamp above all specified parents.
Sourcepub async fn insert_verified(
&mut self,
op: DagOp<T>,
identity: &dyn Identity,
expected_repo_id: Option<&RepoId>,
expected_kind: Option<&str>,
) -> Result<OpId, CobError>
pub async fn insert_verified( &mut self, op: DagOp<T>, identity: &dyn Identity, expected_repo_id: Option<&RepoId>, expected_kind: Option<&str>, ) -> Result<OpId, CobError>
Verifies and idempotently inserts op into the DAG.
Sourcepub fn insert_unchecked(&mut self, op: DagOp<T>) -> Result<OpId, CobError>
pub fn insert_unchecked(&mut self, op: DagOp<T>) -> Result<OpId, CobError>
Inserts an operation whose signature was already checked (or for local construction/tests), still enforcing structural validity and idempotence.
Sourcepub fn tips(&self) -> Vec<OpId>
pub fn tips(&self) -> Vec<OpId>
Returns the causal tips (operations with zero children in this DAG), sorted deterministically.
Trait Implementations§
Source§impl<'de, T> Deserialize<'de> for Dag<T>where
T: Deserialize<'de>,
impl<'de, T> Deserialize<'de> for Dag<T>where
T: Deserialize<'de>,
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>,
Deserialize this value from the given Serde deserializer. Read more
impl<T: Eq> Eq for Dag<T>
impl<T: PartialEq> StructuralPartialEq for Dag<T>
Auto Trait Implementations§
impl<T> Forget for Dag<T>
impl<T> Freeze for Dag<T>
impl<T> Move for Dag<T>
impl<T> RefUnwindSafe for Dag<T>where
T: RefUnwindSafe,
impl<T> Send for Dag<T>
impl<T> Sync for Dag<T>
impl<T> Unpin for Dag<T>
impl<T> UnsafeUnpin for Dag<T>where
*const LeafNode<OpId, DagOp<T>> is !null: UnsafeUnpin,
PhantomData<(Owned, LeafOrInternal)>: UnsafeUnpin,
PhantomData<Box<(OpId, DagOp<T>)>>: UnsafeUnpin,
impl<T> UnwindSafe for Dag<T>
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
Mutably borrows from an owned value. Read more