pub struct NodeFactory<T: Transcendental, const BUF_SIZE: usize> { /* private fields */ }Expand description
Implementations§
Source§impl<T: Transcendental, const BUF_SIZE: usize> NodeFactory<T, BUF_SIZE>
impl<T: Transcendental, const BUF_SIZE: usize> NodeFactory<T, BUF_SIZE>
Sourcepub fn register(&mut self, ctor: impl NodeConstructor<T, BUF_SIZE> + 'static)
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.
Sourcepub fn register_fn(
&mut self,
type_name: &'static str,
f: impl Fn(NodeId, &Params) -> NodeVariant<T, BUF_SIZE> + Send + Sync + 'static,
)
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.
Sourcepub fn construct(
&self,
type_name: &str,
id: NodeId,
params: &Params,
) -> Result<NodeVariant<T, BUF_SIZE>, RegistryError>
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.
Sourcepub fn list_types(&self) -> Vec<&'static str>
pub fn list_types(&self) -> Vec<&'static str>
List all registered type names.
Sourcepub fn metadata(&self, type_name: &str) -> Option<NodeMetadata>
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>
impl<T: Transcendental, const BUF_SIZE: usize> Clone for NodeFactory<T, BUF_SIZE>
Source§impl<T: Transcendental, const BUF_SIZE: usize> Default for NodeFactory<T, BUF_SIZE>
impl<T: Transcendental, const BUF_SIZE: usize> Default for NodeFactory<T, BUF_SIZE>
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more