Skip to main content

Dag

Struct Dag 

Source
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

Source

pub fn new(store: ContentStore) -> Self

Source

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.

Source

pub fn get(&self, hash: &ContentHash) -> Option<&Node>

Get a node by its content hash.

Source

pub fn children(&self, hash: &ContentHash) -> Vec<ContentHash>

Get the direct children of a node (by content hash).

Source

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”

Source

pub fn store(&self) -> &ContentStore

Return a reference to the underlying CAS.

Source

pub fn node_hashes(&self) -> Vec<ContentHash>

Get all node hashes in the DAG.

Source

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