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: &Params) -> NodeVariant<T, BUF_SIZE>;
    fn clone_box(&self) -> Box<dyn NodeConstructor<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 Params 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: &Params) -> NodeVariant<T, BUF_SIZE>

Build a fully initialised node variant.

Implementations should:

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

fn clone_box(&self) -> Box<dyn NodeConstructor<T, BUF_SIZE>>

Clone this constructor into a boxed trait object.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§