musicxml/elements/
backup.rs1use super::{Duration, Footnote, Level};
2use alloc::{string::String, vec::Vec};
3use musicxml_internal::*;
4use musicxml_macros::*;
5
6#[derive(Debug, PartialEq, Eq, ContentDeserialize, ContentSerialize)]
8pub struct BackupContents {
9 pub duration: Duration,
11 pub footnote: Option<Footnote>,
13 pub level: Option<Level>,
15}
16
17#[derive(Debug, PartialEq, Eq, ElementDeserialize, ElementSerialize)]
24pub struct Backup {
25 pub attributes: (),
27 #[flatten]
28 pub content: BackupContents,
30}
31
32#[cfg(test)]
33mod backup_tests {
34 use super::*;
35 use crate::parser::parse_from_xml_str;
36 use crate::{
37 datatypes::PositiveDivisions,
38 elements::{FootnoteAttributes, LevelAttributes},
39 };
40
41 #[test]
42 fn deserialize_valid1() {
43 let result = parse_from_xml_str::<Backup>(
44 "
45 <backup>
46 <duration>2</duration>
47 <footnote>Footnote</footnote>
48 <level>Level</level>
49 </backup>",
50 );
51 assert!(result.is_ok());
52 assert_eq!(
53 result.unwrap(),
54 Backup {
55 attributes: (),
56 content: BackupContents {
57 duration: Duration {
58 attributes: (),
59 content: PositiveDivisions(2)
60 },
61 footnote: Some(Footnote {
62 attributes: FootnoteAttributes::default(),
63 content: String::from("Footnote")
64 }),
65 level: Some(Level {
66 attributes: LevelAttributes::default(),
67 content: String::from("Level")
68 }),
69 }
70 }
71 );
72 }
73}