pub struct Dag { /* private fields */ }Expand description
In-memory DAG with nodes indexed by content hash. Nodes are also serialized into the CAS for persistence.
Implementations§
Source§impl Dag
impl Dag
pub fn new(store: ContentStore) -> Self
Sourcepub fn insert(&mut self, node: Node) -> Result<ContentHash, DagError>
pub fn insert(&mut self, node: Node) -> Result<ContentHash, DagError>
Insert a node into the DAG. Returns its content hash. Deduplicates: if a node with the same hash exists, returns the existing hash.
Sourcepub fn get(&self, hash: &ContentHash) -> Option<&Node>
pub fn get(&self, hash: &ContentHash) -> Option<&Node>
Get a node by its content hash.
Sourcepub fn children(&self, hash: &ContentHash) -> Vec<ContentHash>
pub fn children(&self, hash: &ContentHash) -> Vec<ContentHash>
Get the direct children of a node (by content hash).
Sourcepub fn query(&self, root: &ContentHash, path: &str) -> Option<&Node>
pub fn query(&self, root: &ContentHash, path: &str) -> Option<&Node>
Query the DAG for a node by path, starting from an env or dir root. Path format: “dir/subdir/file.rs”
Sourcepub fn store(&self) -> &ContentStore
pub fn store(&self) -> &ContentStore
Return a reference to the underlying CAS.
Sourcepub fn node_hashes(&self) -> Vec<ContentHash>
pub fn node_hashes(&self) -> Vec<ContentHash>
Get all node hashes in the DAG.
Sourcepub fn parents(&self, target: &ContentHash) -> Vec<ContentHash>
pub fn parents(&self, target: &ContentHash) -> Vec<ContentHash>
Get the parent hashes of a node (all nodes that reference this hash as a child).
Auto Trait Implementations§
impl Freeze for Dag
impl RefUnwindSafe for Dag
impl Send for Dag
impl Sync for Dag
impl Unpin for Dag
impl UnsafeUnpin for Dag
impl UnwindSafe for Dag
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