pub struct Node {
pub id: String,
pub label: String,
pub shape: Shape,
}Expand description
One node: a state, a step, a store. id is unique within the diagram and is what an
Edge names; label is what a reader sees. The two are separate because a label is
prose that may hold spaces, punctuation and a line break, and an id is a token a
renderer writes into its own syntax:
use majordomus_cli::diagram::{Diagram, Kind, Node, Provenance};
let node = Node::new("handed_over", "handed over to the next session");
let drawn = Diagram::new("x", "X", Kind::Flow, Provenance::new("a", "b")).with_node(node);
assert!(drawn.to_mermaid().contains(r#"handed_over["handed over to the next session"]"#));
assert!(drawn.validate().is_empty(), "the id is a token even though the label is not");Fields§
§id: StringUnique within the diagram, and safe to write into Mermaid source unquoted.
label: StringThe short text drawn inside the node.
shape: ShapeWhat it is drawn as.
Implementations§
Source§impl Node
impl Node
Sourcepub fn new(id: impl Into<String>, label: impl Into<String>) -> Node
pub fn new(id: impl Into<String>, label: impl Into<String>) -> Node
A box with this id and label — the node most derivations want.
use majordomus_cli::diagram::{Node, Shape};
let node = Node::new("active", "active");
assert_eq!(node.shape, Shape::Box);
assert_eq!(node.id, "active");Sourcepub fn shaped(self, shape: Shape) -> Node
pub fn shaped(self, shape: Shape) -> Node
The same node with a different Shape — which is a statement about the thing and
not about the picture: a derivation says a node is a store or a terminal, and every
renderer then decides for itself how to draw that.
use majordomus_cli::diagram::{Node, Shape};
let node = Node::new("entry", "entry").shaped(Shape::Terminal);
assert_eq!(node.shape, Shape::Terminal);Trait Implementations§
Source§impl<'de> Deserialize<'de> for Node
impl<'de> Deserialize<'de> for Node
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for Node
Source§impl JsonSchema for Node
impl JsonSchema for Node
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Returns a string that uniquely identifies the schema produced by this type. Read more
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Generates a JSON Schema for this type. Read more
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
Whether JSON Schemas generated for this type should be included directly in parent schemas,
rather than being re-used where possible using the
$ref keyword. Read moreSource§impl Ord for Node
impl Ord for Node
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialOrd for Node
impl PartialOrd for Node
impl StructuralPartialEq for Node
Auto Trait Implementations§
impl Freeze for Node
impl RefUnwindSafe for Node
impl Send for Node
impl Sync for Node
impl Unpin for Node
impl UnsafeUnpin for Node
impl UnwindSafe for Node
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.