Skip to main content

GraphBuilder

Struct GraphBuilder 

Source
pub struct GraphBuilder<T: Transcendental, const BUF_SIZE: usize> { /* private fields */ }
Expand description

Mutable builder for an immutable signal graph.

§Node factory

The builder holds an Arc<NodeFactory> for constructing nodes by type name, provided at construction via GraphBuilder::new.

Implementations§

Source§

impl<T: Transcendental, const BUF_SIZE: usize> GraphBuilder<T, BUF_SIZE>

Source

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.

Source

pub fn add_node( &mut self, type_name: &str, params: &Params, ) -> Result<usize, RegistryError>

Add a node by type name using the internal factory.

The type must have been registered in the factory before calling this method.

Returns the index of the newly added node.

§Errors

Returns RegistryError if no factory is set or the type name is not registered.

Source

pub fn add_node_with_id( &mut self, type_name: &str, params: &Params, id: NodeId, ) -> Result<usize, RegistryError>

Add a node with an explicit NodeId.

Like add_node but uses the provided id. Important for serialization where external references depend on exact IDs.

Source

pub fn set_node_backend(&mut self, idx: usize, name: String)

Assign a named backend to the node at the given index.

During build, the backend is created via the builder’s BackendFactory and passed to the node’s Node::resolve_backend.

Source

pub fn add_resource(&mut self, resource: GraphResource)

Register a named resource (tape loop, buffer, etc.).

Source

pub fn node_count(&self) -> usize

Number of nodes added to the builder so far.

Source

pub fn set_default_backend( &mut self, name: String, params: HashMap<String, ParamValue>, )

Set the default backend name and parameters. Nodes without an explicit backend in [NodeDef::backend] will use this during build.

Source

pub fn default_backend_name(&self) -> Option<&String>

Get the default backend name, if set.

Source

pub fn set_sample_rate(&mut self, sr: f32)

Set the sample rate for this builder.

Source

pub fn set_clock_tx(&mut self, tx: ActorRef<ClockTick>)

Set the clock tick channel (audio → control).

Source

pub fn backend_factory(&self) -> &Arc<BackendFactory<T>>

Access the shared backend factory.

Source

pub fn add_source(&mut self, source: Box<dyn Source<T, BUF_SIZE>>) -> usize

Add a source node and return its index.

Source

pub fn add_processor( &mut self, processor: Box<dyn Processor<T, BUF_SIZE>>, ) -> usize

Add a processor node and return its index.

Source

pub fn add_sink(&mut self, sink: Box<dyn Sink<T, BUF_SIZE>>) -> usize

Add a sink node and return its index.

Source

pub fn add_router(&mut self, router: Box<dyn Router<T, BUF_SIZE>>) -> usize

Add a Router node (N→M configurable routing, no DSP).

Source

pub fn connect_signal( &mut self, from_node: usize, from_port: usize, to_node: usize, to_port: usize, )

Connect signal ports (audio data).

Source

pub fn connect_control( &mut self, from_node: usize, from_port: usize, to_node: usize, to_port: usize, )

Connect control ports (modulation values).

Source

pub fn connect_clock( &mut self, from_node: usize, from_port: usize, to_node: usize, to_port: usize, )

Connect clock ports (timing events).

Source

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).

Source

pub fn build(self) -> Result<Graph<T, BUF_SIZE>, BuildError>

Build the graph.

Creates backends for nodes that have a backend name set (via [NodeDef::backend] or the builder’s default). Finds the active (driver) node and stores its index for Graph::run.

Auto Trait Implementations§

§

impl<T, const BUF_SIZE: usize> Freeze for GraphBuilder<T, BUF_SIZE>

§

impl<T, const BUF_SIZE: usize> !RefUnwindSafe for GraphBuilder<T, BUF_SIZE>

§

impl<T, const BUF_SIZE: usize> !Send for GraphBuilder<T, BUF_SIZE>

§

impl<T, const BUF_SIZE: usize> !Sync for GraphBuilder<T, BUF_SIZE>

§

impl<T, const BUF_SIZE: usize> Unpin for GraphBuilder<T, BUF_SIZE>

§

impl<T, const BUF_SIZE: usize> UnsafeUnpin for GraphBuilder<T, BUF_SIZE>

§

impl<T, const BUF_SIZE: usize> !UnwindSafe for GraphBuilder<T, BUF_SIZE>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> AsAny for T
where T: 'static,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert to &dyn std::any::Any
Source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert to &mut dyn std::any::Any
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V