pub trait BehaviorNode:
Send
+ Sync
+ Debug {
// Required method
fn tick<'life0, 'life1, 'async_trait>(
&'life0 mut self,
ctx: &'life1 Context,
) -> Pin<Box<dyn Future<Output = Result<NodeStatus>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait;
// Provided methods
fn name(&self) -> &str { ... }
fn children_mut(&mut self) -> Vec<&mut dyn BehaviorNode> { ... }
fn active_capability(&self) -> Option<&str> { ... }
fn status_snapshot(&self) -> TreeStatusSnapshot { ... }
fn reset_self(&mut self) { ... }
fn reset<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait { ... }
fn on_init<'life0, 'life1, 'async_trait>(
&'life0 mut self,
ctx: &'life1 Context,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn on_terminate<'life0, 'life1, 'async_trait>(
&'life0 mut self,
ctx: &'life1 Context,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
}Required Methods§
Sourcefn tick<'life0, 'life1, 'async_trait>(
&'life0 mut self,
ctx: &'life1 Context,
) -> Pin<Box<dyn Future<Output = Result<NodeStatus>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn tick<'life0, 'life1, 'async_trait>(
&'life0 mut self,
ctx: &'life1 Context,
) -> Pin<Box<dyn Future<Output = Result<NodeStatus>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Execute one tick of the behavior. Called repeatedly by the execution engine; should
perform one unit of work, return quickly, and report progress via NodeStatus.
Provided Methods§
Sourcefn name(&self) -> &str
fn name(&self) -> &str
Get the name of this behavior node.
Used for debugging, logging, and monitoring.
Sourcefn children_mut(&mut self) -> Vec<&mut dyn BehaviorNode>
fn children_mut(&mut self) -> Vec<&mut dyn BehaviorNode>
Return mutable references to this node’s child behaviors, in the order they should receive lifecycle events. Leaf nodes should not override this; composite nodes override it to expose their children.
Sourcefn active_capability(&self) -> Option<&str>
fn active_capability(&self) -> Option<&str>
The capability this node implies should be published on /behavior/status while it’s
actively being ticked; None for nodes with no such gate (the default). Composite nodes
override this to forward whichever child is currently active.
Sourcefn status_snapshot(&self) -> TreeStatusSnapshot
fn status_snapshot(&self) -> TreeStatusSnapshot
Snapshot of what this node (and, for composite nodes, its subtree) reported on its last
tick(), for live behavior-tree visualization. The default implementation reports
status: None (as if never ticked) and no children - correct for a brand-new node type
that hasn’t been wired up for status tracking yet, but every node type should override
this once it stores a last_status field: leaf nodes return their own last_status,
composite nodes additionally recurse into children_mut’s non-mut counterpart (there’s
no shared non-mut child accessor, so each composite overrides this to walk its own child
collection directly - same pattern as children_mut).
Sourcefn reset_self(&mut self)
fn reset_self(&mut self)
Reset this node’s own local state, ignoring children.
Called by the default reset() before it propagates to children.
Sourcefn reset<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn reset<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Reset the behavior to its initial state.
Called when the behavior needs to be restarted (e.g., in a loop or after a failure).
Sourcefn on_init<'life0, 'life1, 'async_trait>(
&'life0 mut self,
ctx: &'life1 Context,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn on_init<'life0, 'life1, 'async_trait>(
&'life0 mut self,
ctx: &'life1 Context,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Called when the behavior is first initialized.
Use this for one-time setup like loading models, establishing connections, etc.
Sourcefn on_terminate<'life0, 'life1, 'async_trait>(
&'life0 mut self,
ctx: &'life1 Context,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn on_terminate<'life0, 'life1, 'async_trait>(
&'life0 mut self,
ctx: &'life1 Context,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Called when the behavior is being terminated.
Use this for cleanup like closing connections, saving state, etc.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".