Skip to main content

NodeConstructor

Trait NodeConstructor 

Source
pub trait NodeConstructor<T: Transcendental, const BUF_SIZE: usize>: Send + Sync {
    // Required methods
    fn type_name(&self) -> &'static str;
    fn construct(
        &self,
        id: NodeId,
        params: &NodeParams,
    ) -> NodeVariant<T, BUF_SIZE>;
}
Expand description

Factory trait for creating graph nodes by type name.

Each node type that wants to be constructable via the registry implements this trait. The construct method receives a NodeId and NodeParams and must return the appropriate NodeVariant.

Required Methods§

Source

fn type_name(&self) -> &'static str

Canonical name for this node type (e.g. "rill/sine_osc").

Source

fn construct(&self, id: NodeId, params: &NodeParams) -> NodeVariant<T, BUF_SIZE>

Build a fully initialised node variant.

Implementations should:

  1. Extract parameters from params.
  2. Create the concrete node.
  3. Call SignalNode::set_id with the given id.
  4. Call SignalNode::init with params.sample_rate.
  5. Wrap in the correct NodeVariant variant.

Implementors§