Trait hugr_core::hugr::hugrmut::HugrMut

source ·
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§

source

fn get_metadata_mut( &mut self, node: Node, key: impl AsRef<str>, ) -> &mut NodeMetadata

Returns a metadata entry associated with a node.

§Panics

If the node is not in the graph.

source

fn set_metadata( &mut self, node: Node, key: impl AsRef<str>, metadata: impl Into<NodeMetadata>, )

Sets a metadata value associated with a node.

§Panics

If the node is not in the graph.

source

fn take_node_metadata(&mut self, node: Node) -> Option<NodeMetadataMap>

Retrieve the complete metadata map for a node.

source

fn overwrite_node_metadata( &mut self, node: Node, metadata: Option<NodeMetadataMap>, )

Overwrite the complete metadata map for a node.

§Panics

If the node is not in the graph.

source

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.

source

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.

source

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.

source

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.

source

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.

source

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.

source

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.

source

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.

source

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.

source

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.

source

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§

This trait is not object safe.

Implementors§

source§

impl<'g, Root: NodeHandle> HugrMut for SiblingMut<'g, Root>

source§

impl<H: HugrMutInternals + AsRef<Hugr>, Root: NodeHandle> HugrMut for RootChecked<H, Root>

source§

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.