Skip to main content

NodeFactory

Struct NodeFactory 

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

A registry of named node constructors.

Register constructors with register, then create nodes by type name with construct.

§Type parameters

  • T — sample type (typically f32)
  • BUF_SIZE — block size (must match the target graph)

Implementations§

Source§

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

Source

pub fn new() -> Self

Create an empty registry.

Source

pub fn register(&mut self, ctor: impl NodeConstructor<T, BUF_SIZE> + 'static)

Register a node constructor.

The constructor’s type_name is used as the lookup key. If a constructor with the same name already exists, it is replaced.

Source

pub fn register_fn( &mut self, type_name: &'static str, f: impl Fn(NodeId, &Params) -> NodeVariant<T, BUF_SIZE> + Send + Sync + 'static, )

Register a node type via a closure.

This is a convenience wrapper around register for cases where a full struct + trait impl is not needed.

Source

pub fn construct( &self, type_name: &str, id: NodeId, params: &Params, ) -> Result<NodeVariant<T, BUF_SIZE>, RegistryError>

Construct a node by type name.

Returns RegistryError::UnknownType if the name has not been registered.

Source

pub fn contains(&self, type_name: &str) -> bool

Check whether a type name is registered.

Source

pub fn list_types(&self) -> Vec<&'static str>

List all registered type names.

Source

pub fn len(&self) -> usize

Number of registered constructors.

Source

pub fn is_empty(&self) -> bool

True when no constructors are registered.

Source

pub fn metadata(&self, type_name: &str) -> Option<NodeMetadata>

Get metadata for a registered type without constructing a node.

This requires constructing a temporary node and immediately discarding it. If performance is a concern, cache the metadata alongside the constructor in the registry.

Trait Implementations§

Source§

impl<T: Transcendental, const BUF_SIZE: usize> Clone for NodeFactory<T, BUF_SIZE>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Transcendental, const BUF_SIZE: usize> Default for NodeFactory<T, BUF_SIZE>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

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

§

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

§

impl<T, const BUF_SIZE: usize> Send for NodeFactory<T, BUF_SIZE>

§

impl<T, const BUF_SIZE: usize> Sync for NodeFactory<T, BUF_SIZE>

§

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

§

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

§

impl<T, const BUF_SIZE: usize> !UnwindSafe for NodeFactory<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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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