pub struct SubtreeRegistry { /* private fields */ }Expand description
A named registry that maps string keys to reusable subtree factories.
Subtrees are stored as closures that produce a fresh BehaviorNode on
demand; this avoids shared mutable state while still allowing reuse.
Implementations§
Source§impl SubtreeRegistry
impl SubtreeRegistry
pub fn new() -> Self
Sourcepub fn register<F>(&mut self, name: &str, factory: F)where
F: Fn() -> BehaviorNode + 'static,
pub fn register<F>(&mut self, name: &str, factory: F)where
F: Fn() -> BehaviorNode + 'static,
Register a subtree factory under name.
Sourcepub fn instantiate(&self, name: &str) -> Option<BehaviorNode>
pub fn instantiate(&self, name: &str) -> Option<BehaviorNode>
Instantiate the subtree named name, or None if not registered.
pub fn contains(&self, name: &str) -> bool
pub fn names(&self) -> impl Iterator<Item = &str>
Trait Implementations§
Source§impl Debug for SubtreeRegistry
impl Debug for SubtreeRegistry
Auto Trait Implementations§
impl Freeze for SubtreeRegistry
impl !RefUnwindSafe for SubtreeRegistry
impl !Send for SubtreeRegistry
impl !Sync for SubtreeRegistry
impl Unpin for SubtreeRegistry
impl UnsafeUnpin for SubtreeRegistry
impl !UnwindSafe for SubtreeRegistry
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.