pub struct Edge {
pub from: String,
pub to: String,
pub label: Option<String>,
pub style: EdgeStyle,
pub end: EdgeEndpoint,
pub start: EdgeEndpoint,
}Expand description
A directed connection between two nodes.
Fields§
§from: StringID of the source node.
to: StringID of the destination node.
label: Option<String>Optional label placed along the edge.
style: EdgeStyleVisual style of the edge line (solid, dotted, or thick).
end: EdgeEndpointEndpoint drawn at the destination end.
start: EdgeEndpointEndpoint drawn at the source end (for bidirectional edges).
Implementations§
Source§impl Edge
impl Edge
Sourcepub fn new(
from: impl Into<String>,
to: impl Into<String>,
label: Option<String>,
) -> Self
pub fn new( from: impl Into<String>, to: impl Into<String>, label: Option<String>, ) -> Self
Construct a new solid arrow edge (the most common case).
Equivalent to new_styled with EdgeStyle::Solid, EdgeEndpoint::None
at the source, and EdgeEndpoint::Arrow at the destination.
§Arguments
from— source node IDto— destination node IDlabel— optional label placed along the edge
§Examples
use mermaid_text::{Edge, EdgeEndpoint, EdgeStyle};
let e = Edge::new("A", "B", Some("ok".to_string()));
assert_eq!(e.from, "A");
assert_eq!(e.to, "B");
assert_eq!(e.label.as_deref(), Some("ok"));
assert_eq!(e.style, EdgeStyle::Solid);
assert_eq!(e.end, EdgeEndpoint::Arrow);
assert_eq!(e.start, EdgeEndpoint::None);Sourcepub fn new_styled(
from: impl Into<String>,
to: impl Into<String>,
label: Option<String>,
style: EdgeStyle,
start: EdgeEndpoint,
end: EdgeEndpoint,
) -> Self
pub fn new_styled( from: impl Into<String>, to: impl Into<String>, label: Option<String>, style: EdgeStyle, start: EdgeEndpoint, end: EdgeEndpoint, ) -> Self
Construct an edge with explicit style and endpoint kinds.
§Arguments
from— source node IDto— destination node IDlabel— optional label placed along the edgestyle— line style (solid, dotted, thick)start— endpoint at the source endend— endpoint at the destination end
§Examples
use mermaid_text::{Edge, EdgeEndpoint, EdgeStyle};
// A bidirectional thick edge with a label
let e = Edge::new_styled(
"A", "B",
Some("sync".to_string()),
EdgeStyle::Thick,
EdgeEndpoint::Arrow,
EdgeEndpoint::Arrow,
);
assert_eq!(e.style, EdgeStyle::Thick);
assert_eq!(e.start, EdgeEndpoint::Arrow);
assert_eq!(e.end, EdgeEndpoint::Arrow);Trait Implementations§
impl Eq 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