pub struct NodeRegistry { /* private fields */ }Expand description
The NodeRegistry holds all available node types that the engine can construct.
Implementations§
Source§impl NodeRegistry
impl NodeRegistry
Sourcepub fn with_resource_manager(resource_manager: Arc<ResourceManager>) -> Self
pub fn with_resource_manager(resource_manager: Arc<ResourceManager>) -> Self
Creates a new registry with resource management support.
Sourcepub fn set_resource_manager(&mut self, resource_manager: Arc<ResourceManager>)
pub fn set_resource_manager(&mut self, resource_manager: Arc<ResourceManager>)
Sets or updates the resource manager for this registry.
Sourcepub fn register_static<F>(
&mut self,
name: &str,
factory: F,
param_schema: Value,
pins: StaticPins,
categories: Vec<String>,
bidirectional: bool,
)where
F: Fn(Option<&Value>) -> Result<Box<dyn ProcessorNode>, StreamKitError> + Send + Sync + 'static,
pub fn register_static<F>(
&mut self,
name: &str,
factory: F,
param_schema: Value,
pins: StaticPins,
categories: Vec<String>,
bidirectional: bool,
)where
F: Fn(Option<&Value>) -> Result<Box<dyn ProcessorNode>, StreamKitError> + Send + Sync + 'static,
Registers a node with statically defined pins. This is the preferred method for nodes whose input/output pins do not change based on configuration.
Sourcepub fn register_static_with_description<F>(
&mut self,
name: &str,
factory: F,
param_schema: Value,
pins: StaticPins,
categories: Vec<String>,
bidirectional: bool,
description: impl Into<String>,
)where
F: Fn(Option<&Value>) -> Result<Box<dyn ProcessorNode>, StreamKitError> + Send + Sync + 'static,
pub fn register_static_with_description<F>(
&mut self,
name: &str,
factory: F,
param_schema: Value,
pins: StaticPins,
categories: Vec<String>,
bidirectional: bool,
description: impl Into<String>,
)where
F: Fn(Option<&Value>) -> Result<Box<dyn ProcessorNode>, StreamKitError> + Send + Sync + 'static,
Registers a node with statically defined pins and a description.
Sourcepub fn register_dynamic<F>(
&mut self,
name: &str,
factory: F,
param_schema: Value,
categories: Vec<String>,
bidirectional: bool,
)where
F: Fn(Option<&Value>) -> Result<Box<dyn ProcessorNode>, StreamKitError> + Send + Sync + 'static,
pub fn register_dynamic<F>(
&mut self,
name: &str,
factory: F,
param_schema: Value,
categories: Vec<String>,
bidirectional: bool,
)where
F: Fn(Option<&Value>) -> Result<Box<dyn ProcessorNode>, StreamKitError> + Send + Sync + 'static,
Registers a node with dynamically defined pins.
The pin layout for these nodes is determined at instantiation time from their configuration.
The factory for such a node MUST be able to produce a default instance when params is None.
Sourcepub fn register_dynamic_with_description<F>(
&mut self,
name: &str,
factory: F,
param_schema: Value,
categories: Vec<String>,
bidirectional: bool,
description: impl Into<String>,
)where
F: Fn(Option<&Value>) -> Result<Box<dyn ProcessorNode>, StreamKitError> + Send + Sync + 'static,
pub fn register_dynamic_with_description<F>(
&mut self,
name: &str,
factory: F,
param_schema: Value,
categories: Vec<String>,
bidirectional: bool,
description: impl Into<String>,
)where
F: Fn(Option<&Value>) -> Result<Box<dyn ProcessorNode>, StreamKitError> + Send + Sync + 'static,
Registers a node with dynamically defined pins and a description.
Sourcepub fn register_static_with_resource<F>(
&mut self,
name: &str,
factory: F,
resource_factory: AsyncResourceFactory,
resource_key_hasher: ResourceKeyHasher,
param_schema: Value,
pins: StaticPins,
categories: Vec<String>,
bidirectional: bool,
)where
F: Fn(Option<&Value>) -> Result<Box<dyn ProcessorNode>, StreamKitError> + Send + Sync + 'static,
pub fn register_static_with_resource<F>(
&mut self,
name: &str,
factory: F,
resource_factory: AsyncResourceFactory,
resource_key_hasher: ResourceKeyHasher,
param_schema: Value,
pins: StaticPins,
categories: Vec<String>,
bidirectional: bool,
)where
F: Fn(Option<&Value>) -> Result<Box<dyn ProcessorNode>, StreamKitError> + Send + Sync + 'static,
Registers a node with resource management support. This is for nodes that need shared resources like ML models.
§Arguments
name- The unique name for this node typefactory- Factory function that creates node instances (receives params)resource_factory- Async factory that creates/loads the shared resourceresource_key_hasher- Function that hashes params into a cache keyparam_schema- JSON schema for parameter validationpins- Static pin configurationcategories- UI categories for this nodebidirectional- Whether this node is bidirectional
Sourcepub fn register_dynamic_with_resource<F>(
&mut self,
name: &str,
factory: F,
resource_factory: AsyncResourceFactory,
resource_key_hasher: ResourceKeyHasher,
param_schema: Value,
categories: Vec<String>,
bidirectional: bool,
)where
F: Fn(Option<&Value>) -> Result<Box<dyn ProcessorNode>, StreamKitError> + Send + Sync + 'static,
pub fn register_dynamic_with_resource<F>(
&mut self,
name: &str,
factory: F,
resource_factory: AsyncResourceFactory,
resource_key_hasher: ResourceKeyHasher,
param_schema: Value,
categories: Vec<String>,
bidirectional: bool,
)where
F: Fn(Option<&Value>) -> Result<Box<dyn ProcessorNode>, StreamKitError> + Send + Sync + 'static,
Registers a dynamic node with resource management support.
Sourcepub fn create_node(
&self,
name: &str,
params: Option<&Value>,
) -> Result<Box<dyn ProcessorNode>, StreamKitError>
pub fn create_node( &self, name: &str, params: Option<&Value>, ) -> Result<Box<dyn ProcessorNode>, StreamKitError>
Creates an instance of a node by its registered name, passing in its configuration.
§Errors
Returns StreamKitError::Runtime if the node type is not found in the registry,
or if the node’s factory function returns an error during construction.
§Note
This method does not support resource management. For nodes with resources,
use create_node_async instead.
Sourcepub async fn create_node_async(
&self,
name: &str,
params: Option<&Value>,
) -> Result<Box<dyn ProcessorNode>, StreamKitError>
pub async fn create_node_async( &self, name: &str, params: Option<&Value>, ) -> Result<Box<dyn ProcessorNode>, StreamKitError>
Creates an instance of a node asynchronously, with resource management support.
This method should be used for nodes that have resource factories registered. It will load or retrieve shared resources (like ML models) before creating the node instance.
§Errors
Returns StreamKitError::Runtime if the node type is not found in the registry,
if resource initialization fails, or if the node’s factory function returns an error.
Sourcepub fn definitions(&self) -> Vec<NodeDefinition>
pub fn definitions(&self) -> Vec<NodeDefinition>
Returns a list of definitions for all registered nodes.
Sourcepub fn unregister(&mut self, name: &str) -> bool
pub fn unregister(&mut self, name: &str) -> bool
Removes a node definition from the registry. Returns true if a definition with the provided name was present.
Trait Implementations§
Source§impl Clone for NodeRegistry
impl Clone for NodeRegistry
Source§fn clone(&self) -> NodeRegistry
fn clone(&self) -> NodeRegistry
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more