cargo run --example hello_world
cargo run --example event
cargo run --example metadata
cargo run --example memory
requires Rust version 1.41.
```rust use csmlinterpreter::data::csmlbot::CsmlBot; use csmlinterpreter::data::csmlflow::CsmlFlow; use csmlinterpreter::data::event::Event; use csmlinterpreter::data::ContextJson; use csmlinterpreter::interpret; use csmlinterpreter::validate_bot;
const DEFAULTIDNAME: &str = "id"; const DEFAULTFLOWNAME: &str = "flow"; const DEFAULTSTEPNAME: &str = "start"; const DEFAULTBOTNAME: &str = "my_bot";
//////////////////////////////////////////////////////////////////////////////// // PUBLIC FUNCTION ////////////////////////////////////////////////////////////////////////////////
fn main() { let content = std::fs::readtostring("./hello_world.csml").unwrap();
// Create a CsmlFlow
let flow = CsmlFlow::new(
DEFAULT_ID_NAME,
DEFAULT_FLOW_NAME,
&content,
Vec::default()
);
// Create a CsmlBot
let bot = CsmlBot::new(
DEFAULT_ID_NAME,
DEFAULT_BOT_NAME,
None,
vec![flow],
None,
None,
DEFAULT_FLOW_NAME,
);
// Create an Event
let event = Event::default();
// Create a Context
let context = ContextJson::new(
serde_json::json!({}),
serde_json::json!({}),
None,
None,
DEFAULT_STEP_NAME,
DEFAULT_FLOW_NAME,
);
// Run interpreter
let result = validate_bot(bot.to_owned());
if result.errors.is_some() {
dbg!(result.errors);
return;
}
if result.warnings.is_some() {
dbg!(result.warnings);
}
dbg!(interpret(bot, context, event, None));
} ```