pub struct NodeDag<T: Affiliated> { /* private fields */ }
Expand description

The Dag data structure This consists morally of two tables folded in one:

  • the node table, which contains mappings from node hashes to weak references, maintaining which nodes were historically processed by the graph,
  • the heads of the graph (aka the roots): those nodes which do not have antecedents in the graph, and are holding transitive references to all the other nodes.

Those two tables are coalesced into one, which value type is either a weak reference (regular node) or a strong one (heads). During the normal processing of the graph, heads which gain antecedents lost their head status and become regular nodes. Moreover, the transitive references to nodes in the graph may disappear because of its changing topology (see above: path compression). In this case, the weak references may be invalidate. We do not remove them from the graph, and their presence serves as a “tombstone”.

/!\ Warning /!: do not drop the heads of the graph without having given them new antecedents, as this will transitively drop all the nodes they point to and may cause loss of data.

Implementations

Creates a new Node dag

Returns a weak reference to the requested vertex. This does not prevent the vertex from being dropped off the graph.

Returns whether the vertex pointed to by the hash passed as an argument was contained in the DAG at any point in the past.

Returns whether the vertex pointed to by the hash passed as an argument is contained in the DAG and still a live (uncompressed) reference.

Returns an iterator over the digests of the heads of the graph, i.e. the nodes which do not have a child.

Returns whether the vertex pointed to by the hash passed as an argument is a head of the DAG (nodes not pointed to by any other). Heads carry strong references to many downward nodes and dropping them might GC large spans of the graph.

This returns an error if the queried node is unknown

Marks the node passed as argument as compressible, leaving it to be reaped by path compression. Returns true if the node was made compressible, and false if it already was

This return an error if the queried node is unknown or dropped from the graph

Inserts a node in the Dag from the provided value

When the value is inserted, its parent references are interpreted as hash pointers (see Affiliated). Those hash pointers are converted to [NodeRef`] based on the pointed nodes that are already in the DAG.

Note: the dag currently does not do any causal completion. It is an error to insert a node which parents are unknown by the DAG it’s inserted into.

This insertion procedure only maintains the invariant that

  • insertion should be idempotent
  • an unseen node is a head (not pointed) to by any other node.

Performs a breadth-first traversal of the Dag starting at the given vertex

Returns the number of elements (nodes) stored

Trait Implementations

Formats the value using the given formatter. Read more
Returns the “default value” for a type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
Completely overwrites this value.

Returns the argument unchanged.

Called to initialize a place to a valid value, after it is set to all-bits-zero. Read more

Calls U::from(self).

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

The alignment of pointer.
The type for initializers.
Initializes a with the given initializer. Read more
Dereferences the given pointer. Read more
Mutably dereferences the given pointer. Read more
Drops the object pointed to by the given pointer. Read more
Should always be Self
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.