use std::{fmt::Display, str::FromStr};
use serde::{Deserialize, Serialize};
#[cfg_attr(
all(feature = "schemars", not(feature = "test")),
derive(schemars::JsonSchema)
)]
#[derive(Clone, Copy, Debug, Default, Hash, PartialEq, Eq, Deserialize, Serialize)]
#[serde(rename_all = "snake_case")]
pub enum EdgeCurvature {
Curved,
#[default]
Orthogonal,
}
impl EdgeCurvature {
pub fn is_default(&self) -> bool {
matches!(self, EdgeCurvature::Orthogonal)
}
}
impl FromStr for EdgeCurvature {
type Err = ();
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"curved" => Ok(EdgeCurvature::Curved),
"orthogonal" => Ok(EdgeCurvature::Orthogonal),
_ => Err(()),
}
}
}
impl Display for EdgeCurvature {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
EdgeCurvature::Curved => write!(f, "curved"),
EdgeCurvature::Orthogonal => write!(f, "orthogonal"),
}
}
}