Skip to main content

Dag

Struct Dag 

Source
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>

Source

pub fn new() -> Self

Source

pub fn len(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Source

pub fn get(&self, id: &OpId) -> Option<&DagOp<T>>

Source

pub fn contains(&self, id: &OpId) -> bool

Source

pub fn ops(&self) -> &BTreeMap<OpId, DagOp<T>>

Returns all operations indexed by their content-addressed OpId.

Source

pub fn next_lamport(&self, parents: &[OpId]) -> u64

Computes the next valid Lamport timestamp above all specified parents.

Source

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.

Source

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.

Source

pub fn tips(&self) -> Vec<OpId>

Returns the causal tips (operations with zero children in this DAG), sorted deterministically.

Source

pub fn topological_order(&self) -> Result<Vec<(OpId, &DagOp<T>)>, CobError>

Validates causal completeness, Lamport monotonicity, and acyclicity, returning operations in deterministic (lamport, OpId) topological order.

Source

pub fn fold<S, F>(&self, state: S, step: F) -> Result<S, CobError>
where F: FnMut(&mut S, OpId, &DagOp<T>, &BTreeSet<OpId>) -> Result<(), CobError>,

Folds the DAG in deterministic causal topological order, passing each operation and its transitive causal ancestor set to step.

Trait Implementations§

Source§

impl<T: Clone> Clone for Dag<T>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Debug> Debug for Dag<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T> Default for Dag<T>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

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>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<T: Eq> Eq for Dag<T>

Source§

impl<T: PartialEq> PartialEq for Dag<T>

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<T> Serialize for Dag<T>
where T: Serialize,

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<T: PartialEq> StructuralPartialEq for Dag<T>

Auto Trait Implementations§

§

impl<T> Forget for Dag<T>

§

impl<T> Freeze for Dag<T>
where *const LeafNode<OpId, DagOp<T>> is !null: Freeze, PhantomData<(Owned, LeafOrInternal)>: Freeze, PhantomData<Box<(OpId, DagOp<T>)>>: Freeze,

§

impl<T> Move for Dag<T>

§

impl<T> RefUnwindSafe for Dag<T>
where T: RefUnwindSafe,

§

impl<T> Send for Dag<T>
where NodeRef<Owned, OpId, DagOp<T>, LeafOrInternal>: Send, BoxRaw<(OpId, DagOp<T>)>: Send,

§

impl<T> Sync for Dag<T>
where NodeRef<Owned, OpId, DagOp<T>, LeafOrInternal>: Sync, BoxRaw<(OpId, DagOp<T>)>: Sync,

§

impl<T> Unpin for Dag<T>
where *const LeafNode<OpId, DagOp<T>> is !null: Unpin, Box<(OpId, DagOp<T>)>: Unpin,

§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V