pub trait HugrMut: HugrMutInternals {
Show 15 methods
// Provided methods
fn get_metadata_mut(
&mut self,
node: Node,
key: impl AsRef<str>,
) -> &mut NodeMetadata { ... }
fn set_metadata(
&mut self,
node: Node,
key: impl AsRef<str>,
metadata: impl Into<NodeMetadata>,
) { ... }
fn take_node_metadata(&mut self, node: Node) -> Option<NodeMetadataMap> { ... }
fn overwrite_node_metadata(
&mut self,
node: Node,
metadata: Option<NodeMetadataMap>,
) { ... }
fn add_node_with_parent(
&mut self,
parent: Node,
op: impl Into<OpType>,
) -> Node { ... }
fn add_node_before(
&mut self,
sibling: Node,
nodetype: impl Into<OpType>,
) -> Node { ... }
fn add_node_after(&mut self, sibling: Node, op: impl Into<OpType>) -> Node { ... }
fn remove_node(&mut self, node: Node) { ... }
fn connect(
&mut self,
src: Node,
src_port: impl Into<OutgoingPort>,
dst: Node,
dst_port: impl Into<IncomingPort>,
) { ... }
fn disconnect(&mut self, node: Node, port: impl Into<Port>) { ... }
fn add_other_edge(
&mut self,
src: Node,
dst: Node,
) -> (OutgoingPort, IncomingPort) { ... }
fn insert_hugr(&mut self, root: Node, other: Hugr) -> InsertionResult { ... }
fn insert_from_view(
&mut self,
root: Node,
other: &impl HugrView,
) -> InsertionResult { ... }
fn insert_subgraph(
&mut self,
root: Node,
other: &impl HugrView,
subgraph: &SiblingSubgraph,
) -> HashMap<Node, Node> { ... }
fn apply_rewrite<R, E>(
&mut self,
rw: impl Rewrite<ApplyResult = R, Error = E>,
) -> Result<R, E>
where Self: Sized { ... }
}Expand description
Functions for low-level building of a HUGR.
Provided Methods§
sourcefn get_metadata_mut(
&mut self,
node: Node,
key: impl AsRef<str>,
) -> &mut NodeMetadata
fn get_metadata_mut( &mut self, node: Node, key: impl AsRef<str>, ) -> &mut NodeMetadata
sourcefn set_metadata(
&mut self,
node: Node,
key: impl AsRef<str>,
metadata: impl Into<NodeMetadata>,
)
fn set_metadata( &mut self, node: Node, key: impl AsRef<str>, metadata: impl Into<NodeMetadata>, )
sourcefn take_node_metadata(&mut self, node: Node) -> Option<NodeMetadataMap>
fn take_node_metadata(&mut self, node: Node) -> Option<NodeMetadataMap>
Retrieve the complete metadata map for a node.
sourcefn overwrite_node_metadata(
&mut self,
node: Node,
metadata: Option<NodeMetadataMap>,
)
fn overwrite_node_metadata( &mut self, node: Node, metadata: Option<NodeMetadataMap>, )
sourcefn add_node_with_parent(&mut self, parent: Node, op: impl Into<OpType>) -> Node
fn add_node_with_parent(&mut self, parent: Node, op: impl Into<OpType>) -> Node
Add a node to the graph with a parent in the hierarchy.
The node becomes the parent’s last child.
§Panics
If the parent is not in the graph.
sourcefn add_node_before(
&mut self,
sibling: Node,
nodetype: impl Into<OpType>,
) -> Node
fn add_node_before( &mut self, sibling: Node, nodetype: impl Into<OpType>, ) -> Node
Add a node to the graph as the previous sibling of another node.
The sibling node’s parent becomes the new node’s parent.
§Panics
If the sibling is not in the graph, or if the sibling is the root node.
sourcefn add_node_after(&mut self, sibling: Node, op: impl Into<OpType>) -> Node
fn add_node_after(&mut self, sibling: Node, op: impl Into<OpType>) -> Node
Add a node to the graph as the next sibling of another node.
The sibling node’s parent becomes the new node’s parent.
§Panics
If the sibling is not in the graph, or if the sibling is the root node.
sourcefn remove_node(&mut self, node: Node)
fn remove_node(&mut self, node: Node)
Remove a node from the graph.
§Panics
If the node is not in the graph, or if the node is the root node.
sourcefn connect(
&mut self,
src: Node,
src_port: impl Into<OutgoingPort>,
dst: Node,
dst_port: impl Into<IncomingPort>,
)
fn connect( &mut self, src: Node, src_port: impl Into<OutgoingPort>, dst: Node, dst_port: impl Into<IncomingPort>, )
Connect two nodes at the given ports.
§Panics
If either node is not in the graph or if the ports are invalid.
sourcefn disconnect(&mut self, node: Node, port: impl Into<Port>)
fn disconnect(&mut self, node: Node, port: impl Into<Port>)
Disconnects all edges from the given port.
The port is left in place.
§Panics
If the node is not in the graph, or if the port is invalid.
sourcefn add_other_edge(
&mut self,
src: Node,
dst: Node,
) -> (OutgoingPort, IncomingPort)
fn add_other_edge( &mut self, src: Node, dst: Node, ) -> (OutgoingPort, IncomingPort)
Adds a non-dataflow edge between two nodes. The kind is given by the
operation’s OpTrait::other_input or OpTrait::other_output.
Returns the offsets of the new input and output ports.
§Panics
If the node is not in the graph, or if the port is invalid.
sourcefn insert_hugr(&mut self, root: Node, other: Hugr) -> InsertionResult
fn insert_hugr(&mut self, root: Node, other: Hugr) -> InsertionResult
Insert another hugr into this one, under a given root node.
§Panics
If the root node is not in the graph.
sourcefn insert_from_view(
&mut self,
root: Node,
other: &impl HugrView,
) -> InsertionResult
fn insert_from_view( &mut self, root: Node, other: &impl HugrView, ) -> InsertionResult
Copy another hugr into this one, under a given root node.
§Panics
If the root node is not in the graph.
sourcefn insert_subgraph(
&mut self,
root: Node,
other: &impl HugrView,
subgraph: &SiblingSubgraph,
) -> HashMap<Node, Node>
fn insert_subgraph( &mut self, root: Node, other: &impl HugrView, subgraph: &SiblingSubgraph, ) -> HashMap<Node, Node>
Copy a subgraph from another hugr into this one, under a given root node.
Sibling order is not preserved.
The return value is a map from indices in other to the indices of the
corresponding new nodes in self.
§Panics
If the root node is not in the graph.
sourcefn apply_rewrite<R, E>(
&mut self,
rw: impl Rewrite<ApplyResult = R, Error = E>,
) -> Result<R, E>where
Self: Sized,
fn apply_rewrite<R, E>(
&mut self,
rw: impl Rewrite<ApplyResult = R, Error = E>,
) -> Result<R, E>where
Self: Sized,
Applies a rewrite to the graph.
Object Safety§
Implementors§
impl<'g, Root: NodeHandle> HugrMut for SiblingMut<'g, Root>
impl<H: HugrMutInternals + AsRef<Hugr>, Root: NodeHandle> HugrMut for RootChecked<H, Root>
impl<T: RootTagged<RootHandle = Node> + AsMut<Hugr>> HugrMut for T
Impl for non-wrapped Hugrs. Overwrites the recursive default-impls to directly use the hugr.