1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
use alloc::string::String;
use musicxml_internal::{DatatypeDeserializer, DatatypeSerializer};
/// Defines what type of glyph is being defined in a [Glyph][crate::elements::Glyph] element.
#[derive(Debug, PartialEq, Eq)]
pub enum GlyphType {
/// Specifies the glyph to use when a note has a [Rest][crate::elements::Rest] element and a `type` value of quarter.
QuarterRest,
/// Specifies the glyph to use when a clef [Sign][crate::elements::Sign] element value is G and
/// the [ClefOctaveChange][crate::elements::ClefOctaveChange] element value is -1.
GClefOttavaBassa,
/// Specifies the glyph to use when a clef [Sign][crate::elements::Sign] element value is C.
CClef,
/// Specifies the glyph to use when a clef [Sign][crate::elements::Sign] element value is F.
FClef,
/// Specifies the glyph to use when a clef [Sign][crate::elements::Sign] element value is percussion.
PercussionClef,
/// Specifies the glyph to use when an `octave_shift` type attribute value is up and the `size` attribute value is 8.
OctaveShiftUp8,
/// Specifies the glyph to use when an `octave_shift` type attribute value is down and the `size` attribute value is 8.
OctaveShiftDown8,
/// Specifies the glyph to use when an `octave_shift` type attribute value is continue and the `size` attribute value is 8.
OctaveShiftContinue8,
/// Specifies the glyph to use when an `octave_shift` type attribute value is up and the `size` attribute value is 15.
OctaveShiftUp15,
/// Specifies the glyph to use when an `octave_shift` type attribute value is down and the `size` attribute value is 15.
OctaveShiftDown15,
/// Specifies the glyph to use when an `octave_shift` type attribute value is continue and the `size` attribute value is 15.
OctaveShiftContinue15,
/// Specifies the glyph to use when an `octave_shift` type attribute value is up and the `size` attribute value is 22.
OctaveShiftUp22,
/// Specifies the glyph to use when an `octave_shift` type attribute value is down and the `size` attribute value is 22.
OctaveShiftDown22,
/// Specifies the glyph to use when an `octave_shift` type attribute value is continue and the `size` attribute value is 22.
OctaveShiftContinue22,
/// Specifies an application-specific glyph to use.
Other(String),
}
impl DatatypeSerializer for GlyphType {
fn serialize(element: &Self) -> String {
match element {
Self::QuarterRest => String::from("quarter-rest"),
Self::GClefOttavaBassa => String::from("g-clef-ottava-bassa"),
Self::CClef => String::from("c-clef"),
Self::FClef => String::from("f-clef"),
Self::PercussionClef => String::from("percussion-clef"),
Self::OctaveShiftUp8 => String::from("octave-shift-up-8"),
Self::OctaveShiftDown8 => String::from("octave-shift-down-8"),
Self::OctaveShiftContinue8 => String::from("octave-shift-continue-8"),
Self::OctaveShiftUp15 => String::from("octave-shift-up-15"),
Self::OctaveShiftDown15 => String::from("octave-shift-down-15"),
Self::OctaveShiftContinue15 => String::from("octave-shift-continue-15"),
Self::OctaveShiftUp22 => String::from("octave-shift-up-22"),
Self::OctaveShiftDown22 => String::from("octave-shift-down-22"),
Self::OctaveShiftContinue22 => String::from("octave-shift-continue-22"),
Self::Other(text) => text.clone(),
}
}
}
impl DatatypeDeserializer for GlyphType {
fn deserialize(value: &str) -> Result<Self, String> {
Ok(match value {
"quarter-rest" => Self::QuarterRest,
"g-clef-ottava-bassa" => Self::GClefOttavaBassa,
"c-clef" => Self::CClef,
"f-clef" => Self::FClef,
"percussion-clef" => Self::PercussionClef,
"octave-shift-up-8" => Self::OctaveShiftUp8,
"octave-shift-down-8" => Self::OctaveShiftDown8,
"octave-shift-continue-8" => Self::OctaveShiftContinue8,
"octave-shift-up-15" => Self::OctaveShiftUp15,
"octave-shift-down-15" => Self::OctaveShiftDown15,
"octave-shift-continue-15" => Self::OctaveShiftContinue15,
"octave-shift-up-22" => Self::OctaveShiftUp22,
"octave-shift-down-22" => Self::OctaveShiftDown22,
"octave-shift-continue-22" => Self::OctaveShiftContinue22,
_ => Self::Other(String::from(value)),
})
}
}