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