pub trait BehaviorNodeExt: BehaviorNode {
// Provided methods
fn run_until_complete<'life0, 'life1, 'async_trait>(
&'life0 mut self,
ctx: &'life1 Context,
) -> Pin<Box<dyn Future<Output = Result<NodeStatus, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
'life1: 'async_trait,
Self: Send + 'async_trait { ... }
fn run_with_limit<'life0, 'life1, 'async_trait>(
&'life0 mut self,
ctx: &'life1 Context,
max_ticks: usize,
) -> Pin<Box<dyn Future<Output = Result<NodeStatus, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
'life1: 'async_trait,
Self: Send + 'async_trait { ... }
}Expand description
Extension trait for BehaviorNode to provide convenient helpers.
This trait is automatically implemented for all types that implement BehaviorNode.
Provided Methods§
Sourcefn run_until_complete<'life0, 'life1, 'async_trait>(
&'life0 mut self,
ctx: &'life1 Context,
) -> Pin<Box<dyn Future<Output = Result<NodeStatus, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: Send + 'async_trait,
fn run_until_complete<'life0, 'life1, 'async_trait>(
&'life0 mut self,
ctx: &'life1 Context,
) -> Pin<Box<dyn Future<Output = Result<NodeStatus, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: Send + 'async_trait,
Run this behavior until it completes (Success or Failure).
This is a convenience method for testing and simple execution.
§Example
use mecha10_behavior_runtime::prelude::*;
let status = behavior.run_until_complete(ctx).await?;
assert_eq!(status, NodeStatus::Success);Sourcefn run_with_limit<'life0, 'life1, 'async_trait>(
&'life0 mut self,
ctx: &'life1 Context,
max_ticks: usize,
) -> Pin<Box<dyn Future<Output = Result<NodeStatus, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: Send + 'async_trait,
fn run_with_limit<'life0, 'life1, 'async_trait>(
&'life0 mut self,
ctx: &'life1 Context,
max_ticks: usize,
) -> Pin<Box<dyn Future<Output = Result<NodeStatus, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
Self: Send + 'async_trait,
Run this behavior with a maximum number of ticks.
Returns Err if the behavior doesn’t complete within max_ticks.
§Example
use mecha10_behavior_runtime::prelude::*;
let status = behavior.run_with_limit(ctx, 100).await?;