pub struct Registry(/* private fields */);Implementations§
Source§impl Registry
impl Registry
pub fn new() -> Self
Sourcepub fn state<S: Stage + 'static>(
&self,
id: usize,
) -> Result<&S::State, RegistryError>
pub fn state<S: Stage + 'static>( &self, id: usize, ) -> Result<&S::State, RegistryError>
Get a reference to the state of a specific node.
Sourcepub fn state_mut<S: Stage + 'static>(
&mut self,
id: usize,
) -> Result<&mut S::State, RegistryError>
pub fn state_mut<S: Stage + 'static>( &mut self, id: usize, ) -> Result<&mut S::State, RegistryError>
Get a mutable reference to the state of a specific node.
Sourcepub fn register<S: Stage + 'static>(&mut self, stage: S) -> usize
pub fn register<S: Stage + 'static>(&mut self, stage: S) -> usize
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 + 'static>(
&mut self,
stage: S,
state: S::State,
) -> usize
pub fn register_with_state<S: Stage + 'static>( &mut self, stage: S, state: S::State, ) -> usize
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
Sourcepub fn validate_node_type<S: Stage + 'static>(
&self,
id: usize,
) -> Result<(), RegistryError>
pub fn validate_node_type<S: Stage + 'static>( &self, id: usize, ) -> 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: usize,
) -> Result<Option<Node<S>>, RegistryError>
pub fn unregister<S: Stage + 'static>( &mut self, id: usize, ) -> 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: usize) -> Result<(), RegistryError>
pub fn unregister_and_drop(&mut self, id: usize) -> Result<(), RegistryError>
Remove a node from the registry and drop it.
Sourcepub fn get_mut(&mut self, id: usize) -> Option<&mut Box<dyn AnyNode>>
pub fn get_mut(&mut self, id: usize) -> Option<&mut Box<dyn AnyNode>>
Get a mutable type-erased node
Sourcepub fn get2_mut(
&mut self,
id0: usize,
id1: usize,
) -> Result<(&mut Box<dyn AnyNode>, &mut Box<dyn AnyNode>), NodesNotFoundError>
pub fn get2_mut( &mut self, id0: usize, id1: usize, ) -> 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.