dawproject_rs/api/
interpolation.rs

1#![allow(unused)]
2
3use {
4    super::fake_rng,
5    fake::{Dummy, Fake, Faker},
6    serde::{Deserialize, Serialize},
7};
8
9#[derive(Debug, Deserialize, Serialize, Clone, Dummy)]
10#[serde(rename_all = "lowercase")]
11pub enum InterpolationEnum {
12    Hold,
13    Linear,
14}
15
16#[derive(Debug, Deserialize, Serialize, Clone, Dummy)]
17pub struct Interpolation {
18    #[serde(rename = "$value", default)]
19    interpolation_type: Vec<InterpolationEnum>,
20}
21
22impl Interpolation {
23    pub fn new_test(interpolation_type: InterpolationEnum) -> Self {
24        Self {
25            interpolation_type: vec![interpolation_type],
26        }
27    }
28
29    pub fn new_fake() -> Self {
30        let o: Self = Faker.fake_with_rng(&mut fake_rng());
31        o
32    }
33}
34
35#[cfg(test)]
36mod tests {
37    use {
38        super::{Interpolation, InterpolationEnum},
39        quick_xml::se::to_string,
40        std::error::Error,
41    };
42
43    #[test]
44    pub fn se_test() -> Result<(), Box<dyn Error>> {
45        let mut o = Interpolation::new_test(InterpolationEnum::Linear);
46
47        match to_string(&o) {
48            Ok(o) => println!("{}", o),
49            Err(err) => return Err(err.into()),
50        }
51
52        Ok(())
53    }
54}