dawproject_rs/api/timeline_mods/
timeline.rs1#![allow(unused)]
2use {
3 super::{super::add_one_get, super::fake_rng, super::timeline_mods::time_unit::TimeUnit},
4 fake::{Dummy, Fake, Faker},
5 serde::{Deserialize, Serialize},
6};
7
8#[derive(Debug, Deserialize, Serialize, Clone, Dummy)]
9pub struct TimeLine {
10 #[serde(rename = "@id")]
12 #[serde(skip_serializing_if = "Option::is_none")]
13 pub id: Option<String>,
14 #[serde(rename = "@name")]
15 #[serde(skip_serializing_if = "Option::is_none")]
16 pub name: Option<String>,
17 #[serde(rename = "@color")]
18 #[serde(skip_serializing_if = "Option::is_none")]
19 pub color: Option<String>,
20 #[serde(rename = "@comment")]
21 #[serde(skip_serializing_if = "Option::is_none")]
22 pub comment: Option<String>,
23 #[serde(rename = "@track")]
24 #[serde(skip_serializing_if = "Option::is_none")]
25 pub track: Option<String>,
26 #[serde(rename = "@timeUnit")]
27 #[serde(skip_serializing_if = "Option::is_none", default)]
28 pub time_unit: Option<TimeUnit>,
29}
30
31impl TimeLine {
32 pub fn new_test() -> Self {
33 Self {
34 id: Some(format!("id{}", add_one_get())),
35 name: None,
36 color: None,
37 comment: None,
38 track: None,
39 time_unit: None,
40 }
41 }
42
43 pub fn new_fake() -> Self {
44 let o: Self = Faker.fake_with_rng(&mut fake_rng());
45 o
46 }
47}
48
49#[cfg(test)]
50mod tests {
51 use {super::TimeLine, quick_xml::se::to_string, std::error::Error};
52
53 #[test]
54 pub fn se_test() -> Result<(), Box<dyn Error>> {
55 let mut o = TimeLine::new_fake();
56
57 match to_string(&o) {
58 Ok(o) => println!("{}", o),
59 Err(err) => return Err(err.into()),
60 }
61
62 Ok(())
63 }
64}