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