Enum knyst::graph::connection::Connection
source · pub enum Connection {
Node {
source: NodeId,
from_index: Option<usize>,
from_label: Option<&'static str>,
sink: NodeId,
to_index: Option<usize>,
to_label: Option<&'static str>,
to_index_offset: usize,
channels: usize,
feedback: bool,
},
Constant {
value: Sample,
sink: Option<NodeId>,
to_index: Option<usize>,
to_label: Option<&'static str>,
},
GraphOutput {
source: NodeId,
from_index: Option<usize>,
from_label: Option<&'static str>,
to_index: usize,
channels: usize,
},
GraphInput {
sink: NodeId,
from_index: usize,
to_index: Option<usize>,
to_label: Option<&'static str>,
to_index_offset: usize,
channels: usize,
},
Clear {
node: NodeId,
input_nodes: bool,
input_constants: bool,
output_nodes: bool,
graph_outputs: bool,
graph_inputs: bool,
channel: Option<NodeChannel>,
},
GraphInputToOutput {
graph_id: GraphId,
from_input_channel: usize,
to_output_channel: usize,
channels: usize,
},
ClearGraphInputToOutput {
graph_id: GraphId,
from_input_channel: Option<usize>,
to_output_channel: Option<usize>,
channels: Option<usize>,
},
}
Expand description
Connection provides a convenient API for creating connections between nodes in a graph. When used for nodes in a running graph, the shadow engine will translate the Connection to a RtConnection which contains the full Path for finding the correct Graph as fast as possible.
A node can have any number of connections to/from other nodes or outputs. Multiple constant values will result in the sum of all the constants.
Variants§
Node
Fields
from_index: Option<usize>
What output channel from the source node to connect from.
Either from_index or from_label can be used, but index takes precedence if both are set.
from_label: Option<&'static str>
What output channel from the source node to connect from.
Either from_index or from_label can be used, but index takes precedence if both are set.
to_index: Option<usize>
What input channel on the sink node to connect to.
Either to_index or to_label can be used, but index takes precedence if both are set. if input_index and input_label are both None, the default is index 0
to_label: Option<&'static str>
What input channel on the sink node to connect to.
Either to_index or to_label can be used, but index takes precedence if both are set.
to_index_offset: usize
An offset to the destination, useful if targeting a labelled channel and wanting to connect multiple channels in a row.
node to node
Constant
Fields
Set a node input constant. This sets the value immediately if the
Graph
is not running. Otherwise it is equivalent to scheduling a
parameter change as soon as possible.
GraphOutput
Fields
from_index: Option<usize>
What output channel from the source node to connect from.
Either from_index or from_label can be used, but index takes precedence if both are set.
node to graph output
GraphInput
Fields
to_index: Option<usize>
What input channel to connect to.
Either to_index or to_label can be used, but index takes precedence if both are set. if input_index and input_label are both None, the default is index 0
to_label: Option<&'static str>
What input channel to connect to.
Either to_index or to_label can be used, but index takes precedence if both are set. if input_index and input_label are both None, the default is index 0
graph input to node
Clear
Fields
channel: Option<NodeChannel>
Specifies a specific channel to clear. If None (default), clear all.
Clear connections related to a node
GraphInputToOutput
Fields
Connect between a graph input and its output directly
ClearGraphInputToOutput
Fields
from_input_channel: Option<usize>
The index of the first input channel to connect from. If None, disconnect all.
Clear all or specific connection(s) from a input to output within the same graph
Implementations§
source§impl Connection
impl Connection
sourcepub fn graph_output(source_node: NodeId) -> Self
pub fn graph_output(source_node: NodeId) -> Self
Create a connection from source_node
to a graph output
sourcepub fn graph_input(sink_node: NodeId) -> Self
pub fn graph_input(sink_node: NodeId) -> Self
Create a connection from a graph_input to the sink_node
sourcepub fn clear_constants(node: NodeId) -> Self
pub fn clear_constants(node: NodeId) -> Self
Clear input constants of node
sourcepub fn clear_from_nodes(node: NodeId) -> Self
pub fn clear_from_nodes(node: NodeId) -> Self
Clear connections from other nodes to this node
’s input(s)
sourcepub fn clear_to_nodes(node: NodeId) -> Self
pub fn clear_to_nodes(node: NodeId) -> Self
Clear connections from the node
specified to other nodes
sourcepub fn clear_to_graph_outputs(node: NodeId) -> Self
pub fn clear_to_graph_outputs(node: NodeId) -> Self
Clear connections from the node
to the graph outputs
sourcepub fn clear_from_graph_inputs(node: NodeId) -> Self
pub fn clear_from_graph_inputs(node: NodeId) -> Self
Clear connections from the graph inputs to the node
sourcepub fn from(self, source_node: NodeId) -> Self
pub fn from(self, source_node: NodeId) -> Self
Sets the source of a Connection. Only valid for Connection::Node and Connection::GraphOutput. On other variants it does nothing.
sourcepub fn to(self, sink_node: NodeId) -> Self
pub fn to(self, sink_node: NodeId) -> Self
Sets the source of a Connection. Does nothing on a Connection::GraphOutput or Connection::Clear.
sourcepub fn get_from_index(&self) -> Option<usize>
pub fn get_from_index(&self) -> Option<usize>
Get the source channel index of the Connection
if one is set
sourcepub fn get_to_index(&self) -> Option<usize>
pub fn get_to_index(&self) -> Option<usize>
Get the sink channel index of the Connection
if one is set
sourcepub fn from_channel(self, channel: impl Into<NodeChannel>) -> Self
pub fn from_channel(self, channel: impl Into<NodeChannel>) -> Self
Set the source channel
sourcepub fn to_channel(self, channel: impl Into<NodeChannel>) -> Self
pub fn to_channel(self, channel: impl Into<NodeChannel>) -> Self
Set the sink channel
sourcepub fn to_channel_offset(self, offset: usize) -> Self
pub fn to_channel_offset(self, offset: usize) -> Self
Set the sink channel offset
sourcepub fn from_index(self, index: usize) -> Self
pub fn from_index(self, index: usize) -> Self
Set the source channel by index
sourcepub fn from_label(self, label: &'static str) -> Self
pub fn from_label(self, label: &'static str) -> Self
Set the source channel by label
sourcepub fn channels(self, num_channels: usize) -> Self
pub fn channels(self, num_channels: usize) -> Self
Set how many channels should be connected together. This is most useful
for multi channel connections e.g. stereo -> stereo. Inputs/outputs will
wrap if the num_channels
value if higher than the number of
inputs/outputs available.
sourcepub fn feedback(self, activate: bool) -> Self
pub fn feedback(self, activate: bool) -> Self
Set if the connection should be a feedback connection
sourcepub fn get_source_node(&self) -> Option<NodeId>
pub fn get_source_node(&self) -> Option<NodeId>
Get the source node address if one is set and the current variant has one.
Trait Implementations§
source§impl Clone for Connection
impl Clone for Connection
source§fn clone(&self) -> Connection
fn clone(&self) -> Connection
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for Connection
impl Debug for Connection
source§impl Display for Connection
impl Display for Connection
source§impl PartialEq for Connection
impl PartialEq for Connection
source§fn eq(&self, other: &Connection) -> bool
fn eq(&self, other: &Connection) -> bool
self
and other
values to be equal, and is used
by ==
.impl StructuralPartialEq for Connection
Auto Trait Implementations§
impl RefUnwindSafe for Connection
impl Send for Connection
impl Sync for Connection
impl Unpin for Connection
impl UnwindSafe for Connection
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.