mermaid-builder 0.1.2

A Rust library for generating Mermaid diagrams using the builder pattern.
Documentation
//! Enumeration of events associated with a click action on a node in a Mermaid
//! diagram.

mod navigation;
use core::fmt::Display;

pub use navigation::Navigation;
mod js_function_call;
pub use js_function_call::JsFunctionCall;

#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub enum ClickEvent {
    /// Represents a click event that triggers a navigation event,
    /// which can be a external link with or without opening in a new tab,
    /// and that can either be triggered via a real anchor link or a JavaScript
    /// function.
    Navigation(Navigation),
    /// Represents a click event that triggers a JavaScript function call.
    JsFunctionCall(JsFunctionCall),
}

impl Display for ClickEvent {
    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
        match self {
            ClickEvent::Navigation(nav) => write!(f, "{nav}",),
            ClickEvent::JsFunctionCall(js_call) => write!(f, "{js_call}",),
        }
    }
}