pub struct Node {
pub id: String,
pub label: String,
pub shape: NodeShape,
}Expand description
A single node in the diagram.
Fields§
§id: StringUnique identifier used in edge definitions (e.g. A).
label: StringHuman-readable label displayed inside the node box.
shape: NodeShapeVisual shape of the node.
Implementations§
Source§impl Node
impl Node
Sourcepub fn new(
id: impl Into<String>,
label: impl Into<String>,
shape: NodeShape,
) -> Self
pub fn new( id: impl Into<String>, label: impl Into<String>, shape: NodeShape, ) -> Self
Construct a new node.
§Arguments
id— unique identifier used in edge definitionslabel— human-readable text displayed inside the node boxshape— visual shape of the node
§Examples
use mermaid_text::{Node, NodeShape};
let node = Node::new("A", "Start", NodeShape::Rounded);
assert_eq!(node.id, "A");
assert_eq!(node.label, "Start");
assert_eq!(node.shape, NodeShape::Rounded);Sourcepub fn label_width(&self) -> usize
pub fn label_width(&self) -> usize
Return the widest line of the label, measured in terminal cells.
Labels may contain \n line breaks (inserted by the parser when
converting <br/> tags or when soft-wrapping long lines). The
renderer sizes node boxes by the widest single line rather than by
the whole label string, so the parser-inserted breaks actually
narrow the box.
Returns 0 for an empty label.
Sourcepub fn label_line_count(&self) -> usize
pub fn label_line_count(&self) -> usize
Return the number of rendered text rows this node’s label occupies.
Always at least 1, even for empty labels, so node boxes retain their minimum height.
Trait Implementations§
impl Eq 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