use snurr::{Eventhandler, Process}; extern crate pretty_env_logger; #[derive(Debug, Default)] struct Counter { count: u32, } fn main() -> Result<(), Box> { pretty_env_logger::init(); // Create process from BPMN file let bpmn = Process::new("examples/example.bpmn")?; // Create Eventhandler with struct type let mut handler: Eventhandler = Eventhandler::default(); // Register task function for handler. handler.add_task("Count 1", |input| { input.lock().unwrap().count += 1; None }); // Register gateway function for handler. handler.add_gateway("equal to 3", |input| { let result = if input.lock().unwrap().count == 3 { "YES" } else { "NO" }; result.into() }); // Run the process with handler and data let pr = bpmn.run(&handler, Counter::default())?; // Print the result. println!("Result: {:?}", pr.result); Ok(()) }