pub struct Registry(/* private fields */);Implementations§
Source§impl Registry
impl Registry
Sourcepub fn get_node_by_id(&self, id: NodeReflection) -> Option<&Box<dyn AnyNode>>
pub fn get_node_by_id(&self, id: NodeReflection) -> Option<&Box<dyn AnyNode>>
Gets a node by its ID.
Source§impl Registry
impl Registry
pub fn new() -> Self
Sourcepub fn state<S: Stage + 'static>(
&self,
id: NodeId<S>,
) -> Result<&S::State, RegistryError>
pub fn state<S: Stage + 'static>( &self, id: NodeId<S>, ) -> Result<&S::State, RegistryError>
Get a reference to the state of a specific node.
Sourcepub fn state_mut<S: Stage + 'static>(
&mut self,
id: NodeId<S>,
) -> Result<&mut S::State, RegistryError>
pub fn state_mut<S: Stage + 'static>( &mut self, id: NodeId<S>, ) -> Result<&mut S::State, RegistryError>
Get a mutable reference to the state of a specific node.
Sourcepub fn value<T: Send + Sync + Clone + 'static>(
&mut self,
value: T,
) -> NodeId<ValueStage<T>>
pub fn value<T: Send + Sync + Clone + 'static>( &mut self, value: T, ) -> NodeId<ValueStage<T>>
Same as Self::register, but creates a simple stage that just outputs the value given
Sourcepub fn register<S: Stage + Send + Sync + 'static>(
&mut self,
stage: S,
) -> NodeId<S>
pub fn register<S: Stage + Send + Sync + 'static>( &mut self, stage: S, ) -> NodeId<S>
Add a node to the registry. This returns a unique identifier for that node, which can be used to add it to a crate::Graph. This uses default state
Sourcepub fn register_with_state<S: Stage + Send + Sync + 'static>(
&mut self,
stage: S,
state: S::State,
) -> NodeId<S>
pub fn register_with_state<S: Stage + Send + Sync + 'static>( &mut self, stage: S, state: S::State, ) -> NodeId<S>
Add a node to the registry. This returns a unique identifier for that node, which can be used to add it to a crate::Graph.
crate::stage::Stage::State is taken as a tuple of all the state parameters in the order they were defined.
Sourcepub fn validate_node_type<S: Stage + 'static>(
&self,
id: impl Into<NodeReflection>,
) -> Result<(), RegistryError>
pub fn validate_node_type<S: Stage + 'static>( &self, id: impl Into<NodeReflection>, ) -> Result<(), RegistryError>
Returns an error if the registry doesn’t contain a node with a stage of the specified type with the given id.
Sourcepub fn unregister<S: Stage + 'static>(
&mut self,
id: NodeReflection,
) -> Result<Option<Node<S>>, RegistryError>
pub fn unregister<S: Stage + 'static>( &mut self, id: NodeReflection, ) -> Result<Option<Node<S>>, RegistryError>
Remove a node from the registry and return it. This will return an error if S doesn’t match the stage type for that node.
Sourcepub fn unregister_and_drop(
&mut self,
id: impl Into<NodeReflection>,
) -> Result<(), RegistryError>
pub fn unregister_and_drop( &mut self, id: impl Into<NodeReflection>, ) -> Result<(), RegistryError>
Remove a node from the registry and drop it.
Sourcepub fn get_node_any(
&self,
id: impl Into<NodeReflection>,
) -> Option<&Box<dyn AnyNode>>
pub fn get_node_any( &self, id: impl Into<NodeReflection>, ) -> Option<&Box<dyn AnyNode>>
Get a type-erased node
Sourcepub fn get_node_mut<S: Stage + 'static>(
&mut self,
id: NodeId<S>,
) -> Option<&mut Node<S>>
pub fn get_node_mut<S: Stage + 'static>( &mut self, id: NodeId<S>, ) -> Option<&mut Node<S>>
Get a mutable node
Sourcepub fn get_node_any_mut(
&mut self,
id: impl Into<NodeReflection>,
) -> Option<&mut Box<dyn AnyNode>>
pub fn get_node_any_mut( &mut self, id: impl Into<NodeReflection>, ) -> Option<&mut Box<dyn AnyNode>>
Get a mutable type-erased node
Sourcepub fn get2_nodes_any_mut(
&mut self,
id0: NodeReflection,
id1: NodeReflection,
) -> Result<(&mut Box<dyn AnyNode>, &mut Box<dyn AnyNode>), NodesNotFoundError>
pub fn get2_nodes_any_mut( &mut self, id0: NodeReflection, id1: NodeReflection, ) -> Result<(&mut Box<dyn AnyNode>, &mut Box<dyn AnyNode>), NodesNotFoundError>
Get 2 mutable type-erased nodes
This is an important internal detail: a parent a child node often need to be modified together.
This function will panic if id0 and id1 are the same.
Sourcepub fn replace_node(&mut self, id: NodeReflection, node: Box<dyn AnyNode>)
pub fn replace_node(&mut self, id: NodeReflection, node: Box<dyn AnyNode>)
Insert a node with the given ID back into the registry. Panics if the node never existed at that ID in the first place.
Sourcepub fn get_inputs<S: Stage + 'static>(
&self,
node_id: NodeId<S>,
) -> Option<&S::Input>
pub fn get_inputs<S: Stage + 'static>( &self, node_id: NodeId<S>, ) -> Option<&S::Input>
Gets a reference to the inputs from a node
Sourcepub fn get_inputs_mut<S: Stage + 'static>(
&mut self,
node_id: NodeId<S>,
) -> Option<&mut S::Input>
pub fn get_inputs_mut<S: Stage + 'static>( &mut self, node_id: NodeId<S>, ) -> Option<&mut S::Input>
Gets a mutable reference to the inputs from a node