pub trait Network {
type Node: NetworkNode<NodeId = Self::Signal>;
type NodeId: Clone + PartialEq + Eq + Hash + Send + Sync + Debug + 'static;
type Signal: Copy + Clone + PartialEq + Eq + Hash + Send + Sync + Debug + 'static;
type LogicValue: LogicValue;
type NodeFunction: BooleanFunction;
Show 16 methods
// Required methods
fn foreach_gate(&self, f: impl Fn(Self::Signal));
fn foreach_node(&self, f: impl Fn(&Self::Node));
fn get_constant(&self, value: Self::LogicValue) -> Self::Signal;
fn get_constant_value(
&self,
signal: Self::Signal,
) -> Option<Self::LogicValue>;
fn get_node_input(
&self,
node: &Self::NodeId,
input_index: usize,
) -> Self::Signal;
fn get_node_output(&self, node: &Self::NodeId) -> Self::Signal;
fn get_source_node(&self, signal: &Self::Signal) -> Self::NodeId;
fn get_primary_input(&self, index: usize) -> Self::Signal;
fn get_primary_output(&self, index: usize) -> Self::Signal;
fn is_input(&self, signal: Self::Signal) -> bool;
fn node_function(&self, node: Self::NodeId) -> Self::NodeFunction;
fn num_gates(&self) -> usize;
fn num_node_inputs(&self, node: &Self::NodeId) -> usize;
fn num_primary_inputs(&self) -> usize;
fn num_primary_outputs(&self) -> usize;
// Provided method
fn is_constant(&self, signal: Self::Signal) -> bool { ... }
}Expand description
Basic properties of a logic network.
Required Associated Types§
Sourcetype Node: NetworkNode<NodeId = Self::Signal>
type Node: NetworkNode<NodeId = Self::Signal>
Type of the logic node.
Sourcetype NodeId: Clone + PartialEq + Eq + Hash + Send + Sync + Debug + 'static
type NodeId: Clone + PartialEq + Eq + Hash + Send + Sync + Debug + 'static
Identifier of a logic node in this network.
Sourcetype Signal: Copy + Clone + PartialEq + Eq + Hash + Send + Sync + Debug + 'static
type Signal: Copy + Clone + PartialEq + Eq + Hash + Send + Sync + Debug + 'static
Type which represents the outputs of network nodes, e.g. signals. In contrast to a NodeId a Signal might also encode a logic inversion.
Sourcetype LogicValue: LogicValue
type LogicValue: LogicValue
Type of signal values. Typically this might be bool.
Sourcetype NodeFunction: BooleanFunction
type NodeFunction: BooleanFunction
Type which represents the logic function of nodes in the network.
Required Methods§
Sourcefn foreach_gate(&self, f: impl Fn(Self::Signal))
fn foreach_gate(&self, f: impl Fn(Self::Signal))
Visit all network gates in an undefined order. Each gate is visited exactly once.
Sourcefn foreach_node(&self, f: impl Fn(&Self::Node))
fn foreach_node(&self, f: impl Fn(&Self::Node))
Visit all logic nodes.
Sourcefn get_constant(&self, value: Self::LogicValue) -> Self::Signal
fn get_constant(&self, value: Self::LogicValue) -> Self::Signal
Get a graph signal which represents the constant value.
Sourcefn get_constant_value(&self, signal: Self::Signal) -> Option<Self::LogicValue>
fn get_constant_value(&self, signal: Self::Signal) -> Option<Self::LogicValue>
Get the value of a signal if it is a constant.
Sourcefn get_node_input(
&self,
node: &Self::NodeId,
input_index: usize,
) -> Self::Signal
fn get_node_input( &self, node: &Self::NodeId, input_index: usize, ) -> Self::Signal
Get an input value of a node.
Sourcefn get_node_output(&self, node: &Self::NodeId) -> Self::Signal
fn get_node_output(&self, node: &Self::NodeId) -> Self::Signal
Get the output signal of a node.
Sourcefn get_source_node(&self, signal: &Self::Signal) -> Self::NodeId
fn get_source_node(&self, signal: &Self::Signal) -> Self::NodeId
Get the node which computes a signal.
Sourcefn get_primary_input(&self, index: usize) -> Self::Signal
fn get_primary_input(&self, index: usize) -> Self::Signal
Get a primary input by its index.
Sourcefn get_primary_output(&self, index: usize) -> Self::Signal
fn get_primary_output(&self, index: usize) -> Self::Signal
Get a primary output by its index.
Sourcefn node_function(&self, node: Self::NodeId) -> Self::NodeFunction
fn node_function(&self, node: Self::NodeId) -> Self::NodeFunction
Get the logic function implemented by the given node.
Sourcefn num_node_inputs(&self, node: &Self::NodeId) -> usize
fn num_node_inputs(&self, node: &Self::NodeId) -> usize
Number of inputs into the given node.
Sourcefn num_primary_inputs(&self) -> usize
fn num_primary_inputs(&self) -> usize
Number of input into the network.
Sourcefn num_primary_outputs(&self) -> usize
fn num_primary_outputs(&self) -> usize
Number of outputs from the network.
Provided Methods§
Sourcefn is_constant(&self, signal: Self::Signal) -> bool
fn is_constant(&self, signal: Self::Signal) -> bool
Tell if the signal is directly connected to a constant.
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<N: Network + ?Sized> Network for &N
impl<N: Network + ?Sized> Network for &N
Source§type Signal = <N as Network>::Signal
type Signal = <N as Network>::Signal
Type which represents the outputs of network nodes, e.g. signals. In contrast to a NodeId a Signal might also encode a logic inversion.
Source§type LogicValue = <N as Network>::LogicValue
type LogicValue = <N as Network>::LogicValue
Type of signal values. Typically this might be bool.
Source§type NodeFunction = <N as Network>::NodeFunction
type NodeFunction = <N as Network>::NodeFunction
Type which represents the logic function of nodes in the network.
fn foreach_gate(&self, f: impl Fn(Self::Signal))
fn foreach_node(&self, f: impl Fn(&Self::Node))
fn get_constant(&self, value: Self::LogicValue) -> Self::Signal
fn get_constant_value(&self, signal: Self::Signal) -> Option<Self::LogicValue>
fn get_node_input( &self, node: &Self::NodeId, input_index: usize, ) -> Self::Signal
fn get_node_output(&self, node: &Self::NodeId) -> Self::Signal
fn get_source_node(&self, signal: &Self::Signal) -> Self::NodeId
fn get_primary_input(&self, index: usize) -> Self::Signal
fn get_primary_output(&self, index: usize) -> Self::Signal
fn is_constant(&self, signal: Self::Signal) -> bool
fn is_input(&self, signal: Self::Signal) -> bool
fn node_function(&self, node: Self::NodeId) -> Self::NodeFunction
fn num_gates(&self) -> usize
fn num_node_inputs(&self, node: &Self::NodeId) -> usize
fn num_primary_inputs(&self) -> usize
fn num_primary_outputs(&self) -> usize
Source§impl<N: Network + ?Sized> Network for &mut N
impl<N: Network + ?Sized> Network for &mut N
Source§type Signal = <N as Network>::Signal
type Signal = <N as Network>::Signal
Type which represents the outputs of network nodes, e.g. signals. In contrast to a NodeId a Signal might also encode a logic inversion.
Source§type LogicValue = <N as Network>::LogicValue
type LogicValue = <N as Network>::LogicValue
Type of signal values. Typically this might be bool.
Source§type NodeFunction = <N as Network>::NodeFunction
type NodeFunction = <N as Network>::NodeFunction
Type which represents the logic function of nodes in the network.