dawproject_rs/api/timeline_mods/
lanes.rs

1#![allow(unused)]
2use {
3    super::super::{add_one_get, fake_rng},
4    fake::{Dummy, Fake, Faker},
5    serde::{Deserialize, Serialize},
6};
7
8use super::{
9    audio::Audio, clip_slot::ClipSlot, clips::Clips, markers::Markers, notes::Notes,
10    points::Points, time_unit::TimeUnit, timeline::TimeLine, video::Video, warps::Warps,
11};
12
13#[derive(Debug, Deserialize, Serialize, Clone, Dummy)]
14pub enum ArrangementTypeChoiceEnum {
15    Timeline(TimeLine),
16
17    Lanes(Lanes),
18
19    Notes(Notes),
20
21    Clips(Clips),
22
23    ClipSlot(ClipSlot),
24
25    Markers(Markers),
26
27    Warps(Warps),
28
29    Audio(Audio),
30
31    Video(Video),
32
33    Points(Points),
34}
35
36#[derive(Debug, Deserialize, Serialize, Clone, Dummy)]
37pub struct LanesSequence {
38    #[serde(rename = "$value", default)]
39    pub lanes_sequence: Option<LanesSequenceChoice>,
40}
41
42impl LanesSequence {
43    pub fn new() -> Self {
44        Self {
45            lanes_sequence: Some(vec![]),
46        }
47    }
48
49    pub fn new_fake() -> Self {
50        let o: Self = Faker.fake_with_rng(&mut fake_rng());
51        o
52    }
53}
54
55type LanesSequenceChoice = Vec<ArrangementTypeChoiceEnum>;
56
57#[derive(Debug, Deserialize, Serialize, Clone, Dummy)]
58
59pub struct Lanes {
60    #[serde(rename = "@id")]
61    #[serde(skip_serializing_if = "Option::is_none")]
62    pub id: Option<String>,
63    #[serde(rename = "@name")]
64    #[serde(skip_serializing_if = "Option::is_none")]
65    pub name: Option<String>,
66    #[serde(rename = "@color")]
67    #[serde(skip_serializing_if = "Option::is_none")]
68    pub color: Option<String>,
69    #[serde(rename = "@comment")]
70    #[serde(skip_serializing_if = "Option::is_none")]
71    pub comment: Option<String>,
72    #[serde(rename = "@track")]
73    #[serde(skip_serializing_if = "Option::is_none")]
74    pub track: Option<String>,
75    #[serde(rename = "@timeUnit")]
76    #[serde(skip_serializing_if = "Option::is_none", default)]
77    pub time_unit: Option<TimeUnit>,
78    #[serde(rename = "$value", default)]
79    pub lanes_sequence: Option<LanesSequenceChoice>,
80}
81
82impl Lanes {
83    pub fn new_test() -> Self {
84        Self {
85            id: Some(format!("id{}", add_one_get())),
86            name: None,
87            color: None,
88            comment: None,
89            track: None,
90            time_unit: None,
91            lanes_sequence: Some(vec![]),
92        }
93    }
94
95    pub fn new_fake() -> Self {
96        let o: Self = Faker.fake_with_rng(&mut fake_rng());
97        o
98    }
99}
100
101#[cfg(test)]
102mod tests {
103    use {super::Lanes, quick_xml::se::to_string, std::error::Error};
104
105    #[test]
106    pub fn se_test() -> Result<(), Box<dyn Error>> {
107        let mut o = Lanes::new_fake();
108
109        match to_string(&o) {
110            Ok(o) => println!("{}", o),
111            Err(err) => return Err(err.into()),
112        }
113
114        Ok(())
115    }
116}