PortView

Trait PortView 

Source
pub trait PortView {
    type PortOffsetBase: Unsigned;

Show 27 methods // Required methods fn port_direction(&self, port: impl Into<PortIndex>) -> Option<Direction>; fn port_node(&self, port: impl Into<PortIndex>) -> Option<NodeIndex>; fn port_offset( &self, port: impl Into<PortIndex>, ) -> Option<PortOffset<Self::PortOffsetBase>>; fn port_index( &self, node: NodeIndex, offset: PortOffset<Self::PortOffsetBase>, ) -> Option<PortIndex>; fn ports( &self, node: NodeIndex, direction: Direction, ) -> impl Iterator<Item = PortIndex> + Clone; fn all_ports( &self, node: NodeIndex, ) -> impl Iterator<Item = PortIndex> + Clone; fn input(&self, node: NodeIndex, offset: usize) -> Option<PortIndex>; fn output(&self, node: NodeIndex, offset: usize) -> Option<PortIndex>; fn num_ports(&self, node: NodeIndex, direction: Direction) -> usize; fn port_offsets( &self, node: NodeIndex, direction: Direction, ) -> impl Iterator<Item = PortOffset<Self::PortOffsetBase>> + Clone; fn all_port_offsets( &self, node: NodeIndex, ) -> impl Iterator<Item = PortOffset<Self::PortOffsetBase>> + Clone; fn contains_node(&self, node: NodeIndex) -> bool; fn contains_port(&self, port: PortIndex) -> bool; fn is_empty(&self) -> bool; fn node_count(&self) -> usize; fn port_count(&self) -> usize; fn nodes_iter(&self) -> impl Iterator<Item = NodeIndex> + Clone; fn ports_iter(&self) -> impl Iterator<Item = PortIndex> + Clone; fn node_capacity(&self) -> usize; fn port_capacity(&self) -> usize; fn node_port_capacity(&self, node: NodeIndex) -> usize; // Provided methods fn inputs(&self, node: NodeIndex) -> impl Iterator<Item = PortIndex> + Clone { ... } fn outputs( &self, node: NodeIndex, ) -> impl Iterator<Item = PortIndex> + Clone { ... } fn num_inputs(&self, node: NodeIndex) -> usize { ... } fn num_outputs(&self, node: NodeIndex) -> usize { ... } fn input_offsets( &self, node: NodeIndex, ) -> impl Iterator<Item = PortOffset<Self::PortOffsetBase>> + Clone { ... } fn output_offsets( &self, node: NodeIndex, ) -> impl Iterator<Item = PortOffset<Self::PortOffsetBase>> + Clone { ... }
}
Expand description

Core capabilities for querying a graph containing nodes and ports.

Required Associated Types§

Source

type PortOffsetBase: Unsigned

The base unsigned integer type for port offsets.

Required Methods§

Source

fn port_direction(&self, port: impl Into<PortIndex>) -> Option<Direction>

Returns the direction of the port.

Source

fn port_node(&self, port: impl Into<PortIndex>) -> Option<NodeIndex>

Returns the node that the port belongs to.

Source

fn port_offset( &self, port: impl Into<PortIndex>, ) -> Option<PortOffset<Self::PortOffsetBase>>

Returns the index of a port within its node’s port list.

Source

fn port_index( &self, node: NodeIndex, offset: PortOffset<Self::PortOffsetBase>, ) -> Option<PortIndex>

Returns the port index for a given node and offset.

Source

fn ports( &self, node: NodeIndex, direction: Direction, ) -> impl Iterator<Item = PortIndex> + Clone

Iterates over all the ports of the node in the given direction.

Source

fn all_ports(&self, node: NodeIndex) -> impl Iterator<Item = PortIndex> + Clone

Iterates over the input and output ports of the node in sequence.

Source

fn input(&self, node: NodeIndex, offset: usize) -> Option<PortIndex>

Returns the input port at the given offset in the node.

Shorthand for PortView::port_index.

Source

fn output(&self, node: NodeIndex, offset: usize) -> Option<PortIndex>

Returns the output port at the given offset in the node.

Shorthand for PortView::port_index.

Source

fn num_ports(&self, node: NodeIndex, direction: Direction) -> usize

Returns the number of ports of the node in the given direction.

Source

fn port_offsets( &self, node: NodeIndex, direction: Direction, ) -> impl Iterator<Item = PortOffset<Self::PortOffsetBase>> + Clone

Iterates over all the port offsets of the node in the given direction.

§Example
let mut graph: PortGraph = PortGraph::new();
let node = graph.add_node(0, 2);

assert!(graph.links(node, Direction::Incoming).eq([]));
assert!(graph.port_offsets(node, Direction::Outgoing).eq([PortOffset::new_outgoing(0), PortOffset::new_outgoing(1)]));
Source

fn all_port_offsets( &self, node: NodeIndex, ) -> impl Iterator<Item = PortOffset<Self::PortOffsetBase>> + Clone

Iterates over the input and output port offsets of the node in sequence.

Source

fn contains_node(&self, node: NodeIndex) -> bool

Returns whether the port graph contains the node.

Source

fn contains_port(&self, port: PortIndex) -> bool

Returns whether the port graph contains the port.

Source

fn is_empty(&self) -> bool

Returns whether the port graph has no nodes nor ports.

Source

fn node_count(&self) -> usize

Returns the number of nodes in the port graph.

Source

fn port_count(&self) -> usize

Returns the number of ports in the port graph.

Source

fn nodes_iter(&self) -> impl Iterator<Item = NodeIndex> + Clone

Iterates over the nodes in the port graph.

Source

fn ports_iter(&self) -> impl Iterator<Item = PortIndex> + Clone

Iterates over the ports in the port graph.

Source

fn node_capacity(&self) -> usize

Returns the capacity of the underlying buffer for nodes.

Source

fn port_capacity(&self) -> usize

Returns the capacity of the underlying buffer for ports.

Source

fn node_port_capacity(&self, node: NodeIndex) -> usize

Returns the allocated port capacity for a specific node.

Changes to the number of ports of the node will not reallocate until the number of ports exceeds this capacity.

Provided Methods§

Source

fn inputs(&self, node: NodeIndex) -> impl Iterator<Item = PortIndex> + Clone

Iterates over all the input ports of the node.

Shorthand for PortView::ports(Direction::Incoming).

Source

fn outputs(&self, node: NodeIndex) -> impl Iterator<Item = PortIndex> + Clone

Iterates over all the output ports of the node.

Shorthand for PortView::ports(Direction::Outgoing).

Source

fn num_inputs(&self, node: NodeIndex) -> usize

Returns the number of input ports of the node.

Shorthand for PortView::num_ports(Direction::Incoming)..

Source

fn num_outputs(&self, node: NodeIndex) -> usize

Returns the number of output ports of the node.

Shorthand for PortView::num_ports(Direction::Outgoing)..

Source

fn input_offsets( &self, node: NodeIndex, ) -> impl Iterator<Item = PortOffset<Self::PortOffsetBase>> + Clone

Iterates over all the input port offsets of the node.

Shorthand for PortView::port_offsets(Direction::Incoming).

Source

fn output_offsets( &self, node: NodeIndex, ) -> impl Iterator<Item = PortOffset<Self::PortOffsetBase>> + Clone

Iterates over all the output port offsets of the node.

Shorthand for PortView::port_offsets(Direction::Outgoing).

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.

Implementations on Foreign Types§

Source§

impl<G: PortView> PortView for &G

Source§

type PortOffsetBase = <G as PortView>::PortOffsetBase

Source§

fn port_direction(&self, port: impl Into<PortIndex>) -> Option<Direction>

Source§

fn port_node(&self, port: impl Into<PortIndex>) -> Option<NodeIndex>

Source§

fn port_offset( &self, port: impl Into<PortIndex>, ) -> Option<PortOffset<Self::PortOffsetBase>>

Source§

fn port_index( &self, node: NodeIndex, offset: PortOffset<Self::PortOffsetBase>, ) -> Option<PortIndex>

Source§

fn ports( &self, node: NodeIndex, direction: Direction, ) -> impl Iterator<Item = PortIndex> + Clone

Source§

fn all_ports(&self, node: NodeIndex) -> impl Iterator<Item = PortIndex> + Clone

Source§

fn input(&self, node: NodeIndex, offset: usize) -> Option<PortIndex>

Source§

fn output(&self, node: NodeIndex, offset: usize) -> Option<PortIndex>

Source§

fn num_ports(&self, node: NodeIndex, direction: Direction) -> usize

Source§

fn port_offsets( &self, node: NodeIndex, direction: Direction, ) -> impl Iterator<Item = PortOffset<Self::PortOffsetBase>> + Clone

Source§

fn all_port_offsets( &self, node: NodeIndex, ) -> impl Iterator<Item = PortOffset<Self::PortOffsetBase>> + Clone

Source§

fn contains_node(&self, node: NodeIndex) -> bool

Source§

fn contains_port(&self, port: PortIndex) -> bool

Source§

fn is_empty(&self) -> bool

Source§

fn node_count(&self) -> usize

Source§

fn port_count(&self) -> usize

Source§

fn nodes_iter(&self) -> impl Iterator<Item = NodeIndex> + Clone

Source§

fn ports_iter(&self) -> impl Iterator<Item = PortIndex> + Clone

Source§

fn node_capacity(&self) -> usize

Source§

fn port_capacity(&self) -> usize

Source§

fn node_port_capacity(&self, node: NodeIndex) -> usize

Source§

impl<G: PortView> PortView for &mut G

Source§

type PortOffsetBase = <G as PortView>::PortOffsetBase

Source§

fn port_direction(&self, port: impl Into<PortIndex>) -> Option<Direction>

Source§

fn port_node(&self, port: impl Into<PortIndex>) -> Option<NodeIndex>

Source§

fn port_offset( &self, port: impl Into<PortIndex>, ) -> Option<PortOffset<Self::PortOffsetBase>>

Source§

fn port_index( &self, node: NodeIndex, offset: PortOffset<Self::PortOffsetBase>, ) -> Option<PortIndex>

Source§

fn ports( &self, node: NodeIndex, direction: Direction, ) -> impl Iterator<Item = PortIndex> + Clone

Source§

fn all_ports(&self, node: NodeIndex) -> impl Iterator<Item = PortIndex> + Clone

Source§

fn input(&self, node: NodeIndex, offset: usize) -> Option<PortIndex>

Source§

fn output(&self, node: NodeIndex, offset: usize) -> Option<PortIndex>

Source§

fn num_ports(&self, node: NodeIndex, direction: Direction) -> usize

Source§

fn port_offsets( &self, node: NodeIndex, direction: Direction, ) -> impl Iterator<Item = PortOffset<Self::PortOffsetBase>> + Clone

Source§

fn all_port_offsets( &self, node: NodeIndex, ) -> impl Iterator<Item = PortOffset<Self::PortOffsetBase>> + Clone

Source§

fn contains_node(&self, node: NodeIndex) -> bool

Source§

fn contains_port(&self, port: PortIndex) -> bool

Source§

fn is_empty(&self) -> bool

Source§

fn node_count(&self) -> usize

Source§

fn port_count(&self) -> usize

Source§

fn nodes_iter(&self) -> impl Iterator<Item = NodeIndex> + Clone

Source§

fn ports_iter(&self) -> impl Iterator<Item = PortIndex> + Clone

Source§

fn node_capacity(&self) -> usize

Source§

fn port_capacity(&self) -> usize

Source§

fn node_port_capacity(&self, node: NodeIndex) -> usize

Implementors§