-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathregistry_adapter.rs
More file actions
26 lines (23 loc) · 852 Bytes
/
Copy pathregistry_adapter.rs
File metadata and controls
26 lines (23 loc) · 852 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
use mmdflux::builtins::default_registry;
use mmdflux::payload::Diagram;
fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
let input = "graph TD\nA[Draft] --> B[Published]";
let registry = default_registry();
let resolved = registry
.resolve(input)
.expect("built-in registry should detect the flowchart input");
let instance = registry
.create(resolved.diagram_id())
.expect("resolved diagram should have a constructible instance");
let payload = instance.parse(input)?.into_payload()?;
match payload {
Diagram::Flowchart(graph) => {
println!(
"built flowchart graph payload with {} nodes",
graph.nodes.len()
);
}
other => panic!("expected flowchart payload, got {other:?}"),
}
Ok(())
}