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 new() -> Self

Source

pub fn state<S: Stage + 'static>( &self, id: usize, ) -> 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: usize, ) -> Result<&mut S::State, RegistryError>

Get a mutable reference to the state of a specific node.

Source

pub fn register<S: Stage + 'static>(&mut self, stage: S) -> usize
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 + '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

Source

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.

Source

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.

Source

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

Remove a node from the registry and drop it.

Source

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

Get a type-erased node

Source

pub fn get_mut(&mut self, id: usize) -> Option<&mut Box<dyn AnyNode>>

Get a mutable type-erased node

Source

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.

Source§

impl Registry

Source

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

Gets a node by its ID.

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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, 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.