use serde::{Deserialize, Serialize};
#[cfg_attr(alef, alef(skip))]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum DiagramShape {
Box,
Ellipse,
Diamond,
Polygon,
}
impl DiagramShape {
pub fn as_dot(self) -> &'static str {
match self {
Self::Box => "box",
Self::Ellipse => "ellipse",
Self::Diamond => "diamond",
Self::Polygon => "polygon",
}
}
}
#[cfg_attr(alef, alef(skip))]
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct DiagramNode {
pub id: String,
pub label: String,
pub shape: DiagramShape,
pub fill: Option<String>,
pub stroke: Option<String>,
pub stroke_width: Option<f32>,
pub dashed: bool,
}
#[cfg_attr(alef, alef(skip))]
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct DiagramEdge {
pub from: usize,
pub to: usize,
pub bidirectional: bool,
pub label: Option<String>,
pub stroke: Option<String>,
pub dashed: bool,
}
#[cfg_attr(alef, alef(skip))]
#[derive(Debug, Clone, Default, PartialEq, Serialize, Deserialize)]
pub struct DiagramGraph {
pub name: Option<String>,
pub nodes: Vec<DiagramNode>,
pub edges: Vec<DiagramEdge>,
}