snurr/lib.rs
1//! # Snurr
2//!
3//! `Snurr` can run the process flow from a Business Process Model and Notation (BPMN) 2.0 file created by <https://demo.bpmn.io/new>.
4//!
5//! - Add your own behavior with Rust code from a small API. The wiring is already setup from the file.
6//! - Easy to update the BPMN diagram with new Task and Gateways without the need to refactor your old code.
7//! - The BPMN file is the actual design. Forget outdated documentation.
8//! - Scaffold the initial BPMN diagram so you don't have to do the boilerplate code.
9//! - Contains no database.
10//! - Single or multithreaded (opt in)
11//!
12//! This is not a complete implementation of the BPMN 2.0 specification but intend to be a light weight subset of it.
13//!
14//! ## Example
15//!
16//! ### Cargo.toml
17//! ```toml
18//! [dependencies]
19//! snurr = "0.13"
20//! log = "0.4"
21//! pretty_env_logger = "0.5"
22//! ```
23//! ### main.rs
24//!
25//! ```
26//! use snurr::Process;
27//!
28//! extern crate pretty_env_logger;
29//!
30//! #[derive(Debug, Default)]
31//! struct Counter {
32//! count: u32,
33//! }
34//!
35//! fn main() -> Result<(), Box<dyn std::error::Error>> {
36//! pretty_env_logger::init();
37//!
38//! // Create process from BPMN file
39//! let bpmn = Process::<Counter>::new("examples/example.bpmn")?
40//! .task("Count 1", |input| {
41//! input.lock().unwrap().count += 1;
42//! None
43//! })
44//! .exclusive("equal to 3", |input| {
45//! match input.lock().unwrap().count {
46//! 3 => "YES",
47//! _ => "NO",
48//! }
49//! .into()
50//! })
51//! .build()?;
52//!
53//! // Run the process with input data
54//! let counter = bpmn.run(Counter::default())?;
55//!
56//! // Print the result.
57//! println!("Count: {}", counter.count);
58//! Ok(())
59//! }
60//! ```
61
62mod error;
63mod model;
64mod process;
65
66pub use error::{Error, Result};
67pub use model::{Boundary, IntermediateEvent, Symbol, With};
68pub use process::{Build, Process, Run, handler::Data, handler::TaskResult};