NodeRegistry

Struct NodeRegistry 

Source
pub struct NodeRegistry { /* private fields */ }
Expand description

The NodeRegistry holds all available node types that the engine can construct.

Implementations§

Source§

impl NodeRegistry

Source

pub fn new() -> Self

Creates a new, empty registry.

Source

pub fn with_resource_manager(resource_manager: Arc<ResourceManager>) -> Self

Creates a new registry with resource management support.

Source

pub fn set_resource_manager(&mut self, resource_manager: Arc<ResourceManager>)

Sets or updates the resource manager for this registry.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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 type
  • factory - Factory function that creates node instances (receives params)
  • resource_factory - Async factory that creates/loads the shared resource
  • resource_key_hasher - Function that hashes params into a cache key
  • param_schema - JSON schema for parameter validation
  • pins - Static pin configuration
  • categories - UI categories for this node
  • bidirectional - Whether this node is bidirectional
Source

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.

Source

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.

Source

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.

Source

pub fn definitions(&self) -> Vec<NodeDefinition>

Returns a list of definitions for all registered nodes.

Source

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.

Source

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

Checks whether a node definition exists in the registry.

Trait Implementations§

Source§

impl Clone for NodeRegistry

Source§

fn clone(&self) -> NodeRegistry

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Default for NodeRegistry

Source§

fn default() -> NodeRegistry

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

Auto Trait Implementations§

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> 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> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more