Registry

Struct Registry 

Source
pub struct Registry(/* private fields */);
Expand description

A Registry stores each node, its state, and the logical Stage associated with it.

Implementations§

Source§

impl Registry

Source

pub fn get_node_by_id(&self, id: NodeReflection) -> Option<&Box<dyn AnyNode>>

Gets a node by its ID.

Source§

impl Registry

Source

pub fn new() -> Self

Source

pub fn state<S: Stage + 'static>( &self, id: NodeId<S>, ) -> Result<&S::State, RegistryError>

Get a reference to the state of a specific node.

Source

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.

Source

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

Source

pub fn register<S: Stage + Send + Sync + 'static>( &mut self, stage: S, ) -> NodeId<S>
where S::State: Default,

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

Source

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.

Source

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.

Source

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.

Source

pub fn unregister_and_drop( &mut self, id: impl Into<NodeReflection>, ) -> Result<(), RegistryError>

Remove a node from the registry and drop it.

Source

pub fn get_node<S: Stage + 'static>(&self, id: NodeId<S>) -> Option<&Node<S>>

Get a node

Source

pub fn get_node_any( &self, id: impl Into<NodeReflection>, ) -> Option<&Box<dyn AnyNode>>

Get a type-erased node

Source

pub fn get_node_mut<S: Stage + 'static>( &mut self, id: NodeId<S>, ) -> Option<&mut Node<S>>

Get a mutable node

Source

pub fn get_node_any_mut( &mut self, id: impl Into<NodeReflection>, ) -> Option<&mut Box<dyn AnyNode>>

Get a mutable type-erased node

Source

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.

Source

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.

Source

pub fn get_inputs<S: Stage + 'static>( &self, node_id: NodeId<S>, ) -> Option<&S::Input>

Gets a reference to the inputs from a node

Source

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

Source

pub fn get_outputs<S: Stage + 'static>( &self, node_id: NodeId<S>, ) -> Option<&S::Output>

Gets a reference to the outputs from a node

Source

pub fn get_outputs_mut<S: Stage + 'static>( &mut self, node_id: NodeId<S>, ) -> Option<&mut S::Output>

Gets a mutable reference to the outputs from a node

Auto Trait Implementations§

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.