use alloc::string::String;
use musicxml_internal::{DatatypeDeserializer, DatatypeSerializer};
#[derive(Debug, PartialEq, Eq)]
pub enum FermataShape {
Normal,
Angled,
Square,
DoubleAngled,
DoubleSquare,
DoubleDot,
HalfCurve,
Curlew,
Empty,
}
impl DatatypeSerializer for FermataShape {
fn serialize(element: &Self) -> String {
match element {
Self::Normal => String::from("normal"),
Self::Angled => String::from("angled"),
Self::Square => String::from("square"),
Self::DoubleAngled => String::from("double-angled"),
Self::DoubleSquare => String::from("double-square"),
Self::DoubleDot => String::from("double-dot"),
Self::HalfCurve => String::from("half-curve"),
Self::Curlew => String::from("curlew"),
Self::Empty => String::new(),
}
}
}
impl DatatypeDeserializer for FermataShape {
fn deserialize(value: &str) -> Result<Self, String> {
Ok(match value {
"normal" => Self::Normal,
"angled" => Self::Angled,
"square" => Self::Square,
"double-angled" => Self::DoubleAngled,
"double-square" => Self::DoubleSquare,
"double-dot" => Self::DoubleDot,
"half-curve" => Self::HalfCurve,
"curlew" => Self::Curlew,
_ => Self::Empty,
})
}
}