pub struct Group {
pub id: String,
pub label: String,
pub members: Vec<String>,
}Expand description
A box drawn around several nodes: Mermaid’s subgraph. A flowchart concept — a state
machine has composite states instead, which this model does not carry, and
Diagram::validate says so rather than dropping the group in silence.
use majordomus_cli::diagram::{Diagram, Group, Kind, Node, Provenance};
let drawn = Diagram::new("x", "X", Kind::Flow, Provenance::new("a", "b"))
.with_node(Node::new("a", "A"))
.with_node(Node::new("loose", "Loose"))
.with_group(Group::new("canonical", "canonical", ["a"]));
let mermaid = drawn.to_mermaid();
assert!(mermaid.contains(" subgraph canonical [\"canonical\"]\n a[\"A\"]\n end"));
assert!(mermaid.contains("\n loose[\"Loose\"]"), "an ungrouped node stays outside");Fields§
§id: StringUnique within the diagram, and distinct from every node id.
label: StringThe text drawn on the box.
members: Vec<String>The ids of the nodes inside it, in the order they should be drawn.
Implementations§
Source§impl Group
impl Group
Sourcepub fn new(
id: impl Into<String>,
label: impl Into<String>,
members: impl IntoIterator<Item = impl Into<String>>,
) -> Group
pub fn new( id: impl Into<String>, label: impl Into<String>, members: impl IntoIterator<Item = impl Into<String>>, ) -> Group
A group over the node ids given, in that order.
use majordomus_cli::diagram::Group;
let group = Group::new("canonical", "canonical", ["a", "b"]);
assert_eq!(group.members, vec!["a".to_string(), "b".to_string()]);Trait Implementations§
Source§impl<'de> Deserialize<'de> for Group
impl<'de> Deserialize<'de> for Group
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 Group
Source§impl JsonSchema for Group
impl JsonSchema for Group
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 Group
impl Ord for Group
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 Group
impl PartialOrd for Group
impl StructuralPartialEq for Group
Auto Trait Implementations§
impl Freeze for Group
impl RefUnwindSafe for Group
impl Send for Group
impl Sync for Group
impl Unpin for Group
impl UnsafeUnpin for Group
impl UnwindSafe for Group
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.