pub trait MermaidFormat: LinkView + Sized {
// Required method
fn mermaid_format(&self) -> MermaidFormatter<'_, Self>;
// Provided method
fn mermaid_string(&self) -> String { ... }
}Expand description
A trait for encoding a graph in mermaid format.
Required Methods§
Sourcefn mermaid_format(&self) -> MermaidFormatter<'_, Self>
fn mermaid_format(&self) -> MermaidFormatter<'_, Self>
Initialize a MermaidFormatter for the graph.
Call MermaidFormatter::finish to produce the final mermaid string.
Note that mermaid diagrams do not support ports, so graph edges may be unordered.
§Example
let mut graph: PortGraph = PortGraph::new();
let n1 = graph.add_node(3, 2);
let n2 = graph.add_node(0, 1);
let n3 = graph.add_node(1, 0);
graph.link_nodes(n2, 0, n3, 0).unwrap();
let mut hier = Hierarchy::new();
hier.push_child(n2, n1).unwrap();
hier.push_child(n3, n1).unwrap();
let mermaid = graph.mermaid_format().with_hierarchy(&hier).finish();results in
graph LR
subgraph 0 [0]
direction LR
1[1]
1-->2
2[2]
endProvided Methods§
Sourcefn mermaid_string(&self) -> String
fn mermaid_string(&self) -> String
Encode the graph in mermaid format. See
MermaidFormat::mermaid_format for more control over the output
style.
Note that mermaid diagrams do not support ports, so graph edges may be unordered.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.