pub struct Edge {
pub from: String,
pub to: String,
pub label: Option<String>,
pub style: EdgeStyle,
}Expand description
One edge, from a node id to a node id, with the transition or the reason written on it.
An edge names ids and never nodes, so a derivation can state a relationship before it has
built both ends — and Diagram::validate is what refuses an end that never arrived,
rather than a renderer discovering it while writing broken syntax:
use majordomus_cli::diagram::{Diagram, Edge, 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("b", "B"))
.with_edge(Edge::new("a", "b").labelled("moves").dotted());
assert!(drawn.to_mermaid().ends_with("a -.->|moves| b"));Fields§
§from: StringThe id of the node the arrow leaves.
to: StringThe id of the node the arrow reaches.
label: Option<String>What is written on the arrow, when anything is.
style: EdgeStyleWhether it happens or is implied.
Implementations§
Source§impl Edge
impl Edge
Sourcepub fn new(from: impl Into<String>, to: impl Into<String>) -> Edge
pub fn new(from: impl Into<String>, to: impl Into<String>) -> Edge
A plain, unlabelled arrow between two node ids.
use majordomus_cli::diagram::{Edge, EdgeStyle};
let edge = Edge::new("active", "failed");
assert_eq!(edge.label, None);
assert_eq!(edge.style, EdgeStyle::Solid);Sourcepub fn labelled(self, label: impl Into<String>) -> Edge
pub fn labelled(self, label: impl Into<String>) -> Edge
The same arrow with text on it: the command, the event, the condition.
use majordomus_cli::diagram::Edge;
let edge = Edge::new("active", "failed").labelled("finish --outcome failed");
assert_eq!(edge.label.as_deref(), Some("finish --outcome failed"));Trait Implementations§
Source§impl<'de> Deserialize<'de> for Edge
impl<'de> Deserialize<'de> for Edge
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 Edge
Source§impl JsonSchema for Edge
impl JsonSchema for Edge
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 Edge
impl Ord for Edge
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 Edge
impl PartialOrd for Edge
impl StructuralPartialEq for Edge
Auto Trait Implementations§
impl Freeze for Edge
impl RefUnwindSafe for Edge
impl Send for Edge
impl Sync for Edge
impl Unpin for Edge
impl UnsafeUnpin for Edge
impl UnwindSafe for Edge
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.