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§
Sourcefn construct(&self, id: NodeId, params: &NodeParams) -> NodeVariant<T, BUF_SIZE>
fn construct(&self, id: NodeId, params: &NodeParams) -> NodeVariant<T, BUF_SIZE>
Build a fully initialised node variant.
Implementations should:
- Extract parameters from
params. - Create the concrete node.
- Call
SignalNode::set_idwith the givenid. - Call
SignalNode::initwithparams.sample_rate. - Wrap in the correct
NodeVariantvariant.