Skip to main content

Edge

Struct Edge 

Source
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: String

ID of the source node.

§to: String

ID of the destination node.

§label: Option<String>

Optional label placed along the edge.

§style: EdgeStyle

Visual style of the edge line (solid, dotted, or thick).

§end: EdgeEndpoint

Endpoint drawn at the destination end.

§start: EdgeEndpoint

Endpoint drawn at the source end (for bidirectional edges).

Implementations§

Source§

impl Edge

Source

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 ID
  • to — destination node ID
  • label — 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);
Source

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 ID
  • to — destination node ID
  • label — optional label placed along the edge
  • style — line style (solid, dotted, thick)
  • start — endpoint at the source end
  • end — 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§

Source§

impl Clone for Edge

Source§

fn clone(&self) -> Edge

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Edge

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Edge

Source§

fn eq(&self, other: &Edge) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Eq for Edge

Source§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.