pub struct RtTreeBuilder {
pub root: Option<RNodeId>,
pub max: RNodeId,
pub nodes: HashMap<RNodeId, RNode>,
pub actions: HashSet<String>,
}Expand description
The builder for the runtime tree. It is used to build the runtime tree from the tree definition. The builder is used in the tree definition macros.
§Example
use forester_rs::runtime::args::RtArgs;
use forester_rs::runtime::rtree::builder::RtNodeBuilder;
use forester_rs::runtime::rtree::builder::RtTreeBuilder;
use forester_rs::runtime::rtree::rnode::FlowType;
use forester_rs::runtime::rtree::rnode::RNodeName;
use forester_rs::*;
#[test]
fn tree() {
let mut rtb = RtTreeBuilder::new();
let flow = flow!(fallback node_name!("root"), args!();
flow!(sequence node_name!("seq"), args!();
action!(node_name!("action1"))
),
action!(node_name!("action2"))
);
rtb.add_as_root(flow);
let tree = rtb.build().unwrap().0;
}Fields§
§root: Option<RNodeId>§max: RNodeId§nodes: HashMap<RNodeId, RNode>§actions: HashSet<String>Implementations§
Source§impl RtTreeBuilder
impl RtTreeBuilder
Sourcepub fn build(self) -> RtResult<(RuntimeTree, HashSet<String>)>
pub fn build(self) -> RtResult<(RuntimeTree, HashSet<String>)>
Builds the runtime tree from the builder Returns the runtime tree and the set of action names
pub fn new() -> Self
Sourcepub fn add(&mut self, node_b: RtNodeBuilder) -> RNodeId
pub fn add(&mut self, node_b: RtNodeBuilder) -> RNodeId
Generate a new id and adds the node to the builder and returns its id
Sourcepub fn add_as_root(&mut self, node_b: RtNodeBuilder) -> RNodeId
pub fn add_as_root(&mut self, node_b: RtNodeBuilder) -> RNodeId
Generate a new id and adds the node to the builder , sets it as root and returns its id
Sourcepub fn set(&mut self, node_b: RtNodeBuilder, id: RNodeId)
pub fn set(&mut self, node_b: RtNodeBuilder, id: RNodeId)
Sets the node with the given id
Sourcepub fn set_as_root(&mut self, node_b: RtNodeBuilder, id: RNodeId)
pub fn set_as_root(&mut self, node_b: RtNodeBuilder, id: RNodeId)
Sets the node with the given id as root
Trait Implementations§
Auto Trait Implementations§
impl Freeze for RtTreeBuilder
impl RefUnwindSafe for RtTreeBuilder
impl Send for RtTreeBuilder
impl Sync for RtTreeBuilder
impl Unpin for RtTreeBuilder
impl UnwindSafe for RtTreeBuilder
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more