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
use crate::datatypes::{IdRef, TimeOnly, YesNo};
use alloc::{string::String, vec::Vec};
use musicxml_internal::*;
use musicxml_macros::*;
/// Attributes pertaining to the [Assess] element.
#[derive(Debug, PartialEq, Eq, AttributeDeserialize, AttributeSerialize)]
pub struct AssessAttributes {
/// If yes, the note should be assessed; if no, it should not be assessed.
/// If not specified, it is no for notes with a [Cue][super::Cue] child element and yes otherwise.
pub r#type: YesNo,
/// Restricts the type to apply to a single player. If missing, the type applies to all players.
/// It references the `id` attribute of a [Player][super::Player] element defined within the
/// matching [ScorePart][super::ScorePart].
pub player: Option<IdRef>,
/// Restricts the type to apply to a set of times through a repeated section.
/// If missing, the type applies all times through the repeated section.
pub time_only: Option<TimeOnly>,
}
impl Default for AssessAttributes {
fn default() -> Self {
AssessAttributes {
r#type: YesNo::Yes,
player: None,
time_only: None,
}
}
}
/// The [Assess] element allows default [Cue][super::Cue] assessments to be overridden for individual notes.
///
/// By default, an assessment application should assess all notes without a [Cue][super::Cue] child element,
/// and not assess any note with a [Cue][super::Cue] child element.
#[derive(Debug, PartialEq, Eq, ElementDeserialize, ElementSerialize)]
pub struct Assess {
/// Element-specific attributes
pub attributes: AssessAttributes,
/// Element-specific content
pub content: (),
}
#[cfg(test)]
mod assess_tests {
use super::*;
use crate::parser::parse_from_xml_str;
#[test]
fn deserialize_valid1() {
let result = parse_from_xml_str::<Assess>("<assess type=\"yes\" time-only=\"1,2\"></assess>");
assert!(result.is_ok());
assert_eq!(
result.unwrap(),
Assess {
attributes: AssessAttributes {
r#type: YesNo::Yes,
time_only: Some(TimeOnly(vec![1, 2])),
..Default::default()
},
content: ()
}
);
}
}