pub struct GraphBuilder<T: Transcendental, const BUF_SIZE: usize> { /* private fields */ }Expand description
Mutable builder for an immutable signal graph.
Stores deferred node recipes until build, which
constructs all nodes, wires connections, and performs topological
sort. This keeps GraphBuilder Send — all non‑Send data
is constructed inside the target thread.
§Node factory
The builder holds an Arc<NodeFactory> for constructing nodes by
type name. Nodes registered via add_node_with_id
are only validated and constructed at build time.
Implementations§
Source§impl<T: Transcendental, const BUF_SIZE: usize> GraphBuilder<T, BUF_SIZE>
impl<T: Transcendental, const BUF_SIZE: usize> GraphBuilder<T, BUF_SIZE>
Sourcepub fn new(
factory: Arc<NodeFactory<T, BUF_SIZE>>,
backend_factory: Arc<BackendFactory<T>>,
) -> Self
pub fn new( factory: Arc<NodeFactory<T, BUF_SIZE>>, backend_factory: Arc<BackendFactory<T>>, ) -> Self
Create a new empty graph builder without a node factory.
Sourcepub fn add_node(&mut self, type_name: &str, params: &Params) -> usize
pub fn add_node(&mut self, type_name: &str, params: &Params) -> usize
Add a node by type name using the internal factory.
The type must be registered in the factory before build
is called.
Returns the index of the newly added node.
Sourcepub fn set_node_backend(&mut self, idx: usize, name: String)
pub fn set_node_backend(&mut self, idx: usize, name: String)
Assign a named backend to the node at the given index.
Sourcepub fn add_routing_entry(
&mut self,
idx: usize,
from: usize,
to: usize,
gain: f32,
)
pub fn add_routing_entry( &mut self, idx: usize, from: usize, to: usize, gain: f32, )
Store a routing matrix entry to be applied at build time.
Sourcepub fn add_resource(&mut self, resource: GraphResource)
pub fn add_resource(&mut self, resource: GraphResource)
Register a named resource (tape loop, buffer, etc.).
Sourcepub fn node_count(&self) -> usize
pub fn node_count(&self) -> usize
Number of nodes added to the builder so far.
Sourcepub fn set_default_backend(
&mut self,
name: String,
params: HashMap<String, ParamValue>,
)
pub fn set_default_backend( &mut self, name: String, params: HashMap<String, ParamValue>, )
Set the default backend name and parameters. Nodes without an explicit
Sourcepub fn default_backend_name(&self) -> Option<&String>
pub fn default_backend_name(&self) -> Option<&String>
Get the default backend name, if set.
Sourcepub fn set_sample_rate(&mut self, sr: f32)
pub fn set_sample_rate(&mut self, sr: f32)
Set the sample rate for this builder.
Sourcepub fn set_parent_ref(&mut self, parent: ActorRef<CommandEnum>)
pub fn set_parent_ref(&mut self, parent: ActorRef<CommandEnum>)
Set the parent RackCase actor reference (Graph → parent ClockTick).
Sourcepub fn backend_factory(&self) -> &Arc<BackendFactory<T>>
pub fn backend_factory(&self) -> &Arc<BackendFactory<T>>
Access the shared backend factory.
Sourcepub fn connect_signal(
&mut self,
from_node: usize,
from_port: usize,
to_node: usize,
to_port: usize,
)
pub fn connect_signal( &mut self, from_node: usize, from_port: usize, to_node: usize, to_port: usize, )
Connect signal ports.
Sourcepub fn connect_control(
&mut self,
from_node: usize,
from_port: usize,
to_node: usize,
to_port: usize,
)
pub fn connect_control( &mut self, from_node: usize, from_port: usize, to_node: usize, to_port: usize, )
Connect control ports (modulation values).
Sourcepub fn connect_clock(
&mut self,
from_node: usize,
from_port: usize,
to_node: usize,
to_port: usize,
)
pub fn connect_clock( &mut self, from_node: usize, from_port: usize, to_node: usize, to_port: usize, )
Connect clock ports (timing events).
Sourcepub fn connect_feedback(
&mut self,
from_node: usize,
from_port: usize,
to_node: usize,
to_port: usize,
)
pub fn connect_feedback( &mut self, from_node: usize, from_port: usize, to_node: usize, to_port: usize, )
Connect feedback ports (delay lines, state carryover).
Sourcepub fn build(
self,
system: &ActorSystem,
) -> Result<Graph<T, BUF_SIZE>, BuildError>
pub fn build( self, system: &ActorSystem, ) -> Result<Graph<T, BUF_SIZE>, BuildError>
Build the graph.
Creates backends for nodes that have a backend name set (via
SourceDef::backend / SinkDef::backend or the builder’s default). Finds the active
(driver) node and stores its index for Graph::run.