pub struct NirGraph {
pub nodes: IndexMap<String, NirNode>,
pub edges: Vec<(String, String)>,
pub metadata: HashMap<String, MetadataValue>,
pub version: Option<String>,
}Expand description
Directed NIR computation graph.
Node insertion order is preserved via IndexMap (stable iteration for
serialization and debugging). Edges are an ordered list of (src, dst)
name pairs.
Fields§
§nodes: IndexMap<String, NirNode>Named computational nodes (insertion-ordered).
edges: Vec<(String, String)>Directed edges as (source_name, destination_name).
metadata: HashMap<String, MetadataValue>Free-form graph metadata.
version: Option<String>Optional NIR version string (set when loading from HDF5 in v0.3).
Implementations§
Source§impl NirGraph
impl NirGraph
Sourcepub fn add_edge(&mut self, from: impl Into<String>, to: impl Into<String>)
pub fn add_edge(&mut self, from: impl Into<String>, to: impl Into<String>)
Append a directed edge (from → to) without validating endpoints.
Call validate_structure to check that
endpoints exist and that the edge is not duplicated.
Sourcepub fn get_mut(&mut self, name: &str) -> Option<&mut NirNode>
pub fn get_mut(&mut self, name: &str) -> Option<&mut NirNode>
Mutably borrow the node named name, if present.
Sourcepub fn validate_structure(&self) -> Result<()>
pub fn validate_structure(&self) -> Result<()>
Validate structural integrity.
Checks:
- every edge endpoint names an existing node
- no duplicate directed edges
(src, dst) - nested
NirNode::Graphsubgraphs also validate
Cycles are allowed. Type/shape inference is out of scope for v0.2.
§Errors
NirError::MissingNodeif an endpoint is unknownNirError::DuplicateEdgeif the same directed edge appears twiceNirError::InvalidGraphif a nested subgraph fails validation
Trait Implementations§
impl StructuralPartialEq for NirGraph
Auto Trait Implementations§
impl Freeze for NirGraph
impl RefUnwindSafe for NirGraph
impl Send for NirGraph
impl Sync for NirGraph
impl Unpin for NirGraph
impl UnsafeUnpin for NirGraph
impl UnwindSafe for NirGraph
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