Skip to main content

load

Function load 

Source
pub fn load(input: &str) -> Result<Document, Error>
Expand description

detect + parse. Process text and compact JSON are expanded (and laid out) into a BPMN or DMN document. Expansion does not apply the Camunda 8 deploy gate, so a draft still loads; run the lint crate to find what Zeebe would refuse.

Examples found in repository?
examples/eval_dmn.rs (line 19)
18fn main() -> Result<(), Box<dyn std::error::Error>> {
19    let Document::Dmn(definitions) = load(DMN)? else {
20        unreachable!("the input is DMN");
21    };
22    let mut vars = Context::new();
23    vars.insert("amount", 1500);
24    let out = evaluate_decision_graph(&definitions, "tier", &vars)?;
25    println!("tier = {}", out.result);
26    Ok(())
27}
More examples
Hide additional examples
examples/text_to_bpmn.rs (line 10)
5fn main() -> Result<(), Error> {
6    let text = "# Expense approval\n\
7        start[start Expense submitted] > check[xor Amount over 1000?]\n\
8        check >(Yes: amount > 1000) review[user Review expense] > done[end Paid]\n\
9        check >(No: default) auto[service Approve automatically] > done\n";
10    let Document::Bpmn(definitions) = load(text)? else {
11        unreachable!("process text always expands to BPMN");
12    };
13    println!("{}", serialize_bpmn(&definitions));
14    Ok(())
15}
examples/lint_report.rs (line 14)
8fn main() -> Result<(), Error> {
9    // A start event with nothing after it.
10    let xml = r#"<?xml version="1.0" encoding="UTF-8"?>
11<bpmn:definitions xmlns:bpmn="http://www.omg.org/spec/BPMN/20100524/MODEL" id="D" targetNamespace="http://bpmn.io/schema/bpmn">
12  <bpmn:process id="p" isExecutable="true"><bpmn:startEvent id="s"/></bpmn:process>
13</bpmn:definitions>"#;
14    let Document::Bpmn(definitions) = load(xml)? else {
15        unreachable!("the input is BPMN");
16    };
17    let report = lint_diagram(&definitions, LintOptions::default());
18    println!(
19        "{}",
20        to_text(
21            &report,
22            &TextStyle {
23                color: false,
24                max: 10
25            }
26        )
27    );
28    println!("{}", to_markdown(&report));
29    println!("{}", to_slack_mrkdwn(&report));
30    Ok(())
31}