Skip to main content

BehaviorNode

Trait BehaviorNode 

Source
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 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§

Source

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§

Source

fn name(&self) -> &str

Get the name of this behavior node.

Used for debugging, logging, and monitoring.

Source

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.

Source

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.

Source

fn reset_self(&mut self)

Reset this node’s own local state, ignoring children.

Called by the default reset() before it propagates to children.

Source

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

Source

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.

Source

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

Implementors§