pub trait LinkMut: LinkView + PortMut {
// Required methods
fn link_ports(
&mut self,
port_a: PortIndex,
port_b: PortIndex,
) -> Result<(Self::LinkEndpoint, Self::LinkEndpoint), LinkError<Self::PortOffsetBase>>;
fn unlink_port(&mut self, port: PortIndex) -> Option<Self::LinkEndpoint>;
// Provided methods
fn link_nodes(
&mut self,
from: NodeIndex,
from_output: usize,
to: NodeIndex,
to_input: usize,
) -> Result<(Self::LinkEndpoint, Self::LinkEndpoint), LinkError<Self::PortOffsetBase>> { ... }
fn link_offsets(
&mut self,
node_a: NodeIndex,
offset_a: PortOffset<Self::PortOffsetBase>,
node_b: NodeIndex,
offset_b: PortOffset<Self::PortOffsetBase>,
) -> Result<(Self::LinkEndpoint, Self::LinkEndpoint), LinkError<Self::PortOffsetBase>> { ... }
fn insert_graph(
&mut self,
other: &impl LinkView<PortOffsetBase = Self::PortOffsetBase>,
) -> Result<HashMap<NodeIndex, NodeIndex>, LinkError<Self::PortOffsetBase>> { ... }
}Expand description
Mutating operations pertaining the adjacency of nodes in a port graph.
Required Methods§
Sourcefn link_ports(
&mut self,
port_a: PortIndex,
port_b: PortIndex,
) -> Result<(Self::LinkEndpoint, Self::LinkEndpoint), LinkError<Self::PortOffsetBase>>
fn link_ports( &mut self, port_a: PortIndex, port_b: PortIndex, ) -> Result<(Self::LinkEndpoint, Self::LinkEndpoint), LinkError<Self::PortOffsetBase>>
Link an output port to an input port.
§Example
let mut g: PortGraph = PortGraph::new();
let node0 = g.add_node(0, 1);
let node1 = g.add_node(1, 0);
let node0_output = g.output(node0, 0).unwrap();
let node1_input = g.input(node1, 0).unwrap();
g.link_ports(node0_output, node1_input).unwrap();
assert_eq!(g.port_link(node0_output), Some(node1_input));
assert_eq!(g.port_link(node1_input), Some(node0_output));§Errors
- If
port_aorport_bdoes not exist. - If
port_aandport_bhave the same direction.
Sourcefn unlink_port(&mut self, port: PortIndex) -> Option<Self::LinkEndpoint>
fn unlink_port(&mut self, port: PortIndex) -> Option<Self::LinkEndpoint>
Unlinks all connections to the port. If the port was connected,
returns one of the ports it was connected to.
Provided Methods§
Sourcefn link_nodes(
&mut self,
from: NodeIndex,
from_output: usize,
to: NodeIndex,
to_input: usize,
) -> Result<(Self::LinkEndpoint, Self::LinkEndpoint), LinkError<Self::PortOffsetBase>>
fn link_nodes( &mut self, from: NodeIndex, from_output: usize, to: NodeIndex, to_input: usize, ) -> Result<(Self::LinkEndpoint, Self::LinkEndpoint), LinkError<Self::PortOffsetBase>>
Sourcefn link_offsets(
&mut self,
node_a: NodeIndex,
offset_a: PortOffset<Self::PortOffsetBase>,
node_b: NodeIndex,
offset_b: PortOffset<Self::PortOffsetBase>,
) -> Result<(Self::LinkEndpoint, Self::LinkEndpoint), LinkError<Self::PortOffsetBase>>
fn link_offsets( &mut self, node_a: NodeIndex, offset_a: PortOffset<Self::PortOffsetBase>, node_b: NodeIndex, offset_b: PortOffset<Self::PortOffsetBase>, ) -> Result<(Self::LinkEndpoint, Self::LinkEndpoint), LinkError<Self::PortOffsetBase>>
Links two nodes at an input and output port offsets.
§Errors
- If the ports and nodes do not exist.
- If the ports have the same direction.
Sourcefn insert_graph(
&mut self,
other: &impl LinkView<PortOffsetBase = Self::PortOffsetBase>,
) -> Result<HashMap<NodeIndex, NodeIndex>, LinkError<Self::PortOffsetBase>>
fn insert_graph( &mut self, other: &impl LinkView<PortOffsetBase = Self::PortOffsetBase>, ) -> Result<HashMap<NodeIndex, NodeIndex>, LinkError<Self::PortOffsetBase>>
Inserts another graph into this graph.
Returns a map from the old node indices to the new node indices.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.