pub struct SimulatorBuilder { /* private fields */ }Expand description
The builder to create a simulator process.
§Examples
use std::path::PathBuf;
use forester_rs::runtime::builder::ForesterBuilder;
use forester_rs::simulator::builder::SimulatorBuilder;
fn smoke() {
let mut sb = SimulatorBuilder::new();
let root = PathBuf::from("simulator/smoke");
sb.root(root.clone());
sb.profile(PathBuf::from("sim.yaml"));
let mut fb = ForesterBuilder::from_fs();
fb.main_file("main.tree".to_string());
fb.root(root);
sb.forester_builder(fb);
let mut sim = sb.build().unwrap();
sim.run().unwrap();
}
fn smoke_from_text() {
let mut sb = SimulatorBuilder::new();
let sim = PathBuf::from("simulator/smoke/sim.yaml");
let mut fb = ForesterBuilder::from_text();
sb.profile(sim);
fb.text(
r#"
import "std::actions"
root main sequence {
store("info1", "initial")
retryer(task(config = obj), success())
store("info2","finish")
}
fallback retryer(t:tree, default:tree){
retry(5) t(..)
fail("just should fail")
default(..)
}
impl task(config: object);
"#
.to_string(),
);
sb.forester_builder(fb);
let mut sim = sb.build().unwrap();
sim.run().unwrap();
}Implementations§
Source§impl SimulatorBuilder
impl SimulatorBuilder
pub fn new() -> Self
Sourcepub fn forester_builder(&mut self, fb: ForesterBuilder)
pub fn forester_builder(&mut self, fb: ForesterBuilder)
Add an ForesterBuilder instance.
Use ForesterBuilder for that.
Trait Implementations§
Source§impl Default for SimulatorBuilder
impl Default for SimulatorBuilder
Source§fn default() -> SimulatorBuilder
fn default() -> SimulatorBuilder
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl !Freeze for SimulatorBuilder
impl !RefUnwindSafe for SimulatorBuilder
impl Send for SimulatorBuilder
impl Sync for SimulatorBuilder
impl Unpin for SimulatorBuilder
impl !UnwindSafe for SimulatorBuilder
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