l6t_file/
model.rs

1use std::fmt::{Display, Formatter, Result};
2
3#[derive(Debug)]
4pub struct TargetDevice {
5    pub midi_id: u32,
6    pub name: String,
7    pub version: u32
8}
9
10#[derive(Debug)]
11pub struct Model {
12    pub model_id: u32,
13    pub slot_id: u32,
14    pub enabled: bool,
15    pub ordinal: u8,
16    pub params: Vec<ModelParam>
17}
18
19impl PartialEq for Model {
20    fn eq(&self, other: &Self) -> bool {
21        self.slot_id == other.slot_id &&
22            self.model_id == other.model_id &&
23            self.ordinal == other.ordinal
24    }
25}
26
27#[derive(Debug)]
28pub struct ModelParam {
29    pub param_id: u32,
30    pub value: Value
31}
32
33#[derive(Debug)]
34pub enum Value {
35    Int(u32),
36    Float(f32)
37}
38
39#[derive(Debug)]
40pub struct MetaTags {
41    pub author: String,
42    pub guitarist: String,
43    pub band: String,
44    pub song: String,
45    pub style: String,
46    pub pickup_style: String,
47    pub pickup_position: String,
48    pub date: usize,
49    pub amp_name: String,
50    pub creator_app: String,
51    pub creator_app_version: String,
52    pub comments: String
53}
54
55#[derive(Debug)]
56pub struct L6Patch {
57    pub target_device: TargetDevice,
58    pub models: Vec<Model>,
59    pub meta: MetaTags
60}
61
62impl Default for MetaTags {
63    fn default() -> Self {
64        MetaTags {
65            author: "".to_string(),
66            guitarist: "".to_string(),
67            band: "".to_string(),
68            song: "".to_string(),
69            style: "".to_string(),
70            pickup_style: "".to_string(),
71            pickup_position: "".to_string(),
72            date: 0,
73            amp_name: "".to_string(),
74            creator_app: "".to_string(),
75            creator_app_version: "".to_string(),
76            comments: "".to_string()
77        }
78    }
79}
80
81impl Default for TargetDevice {
82    fn default() -> Self {
83        TargetDevice {
84            midi_id: 0,
85            name: "".to_string(),
86            version: 0
87        }
88    }
89}
90
91impl Default for L6Patch {
92    fn default() -> Self {
93        L6Patch {
94            target_device: Default::default(),
95            models: Default::default(),
96            meta: Default::default()
97        }
98    }
99}
100
101impl Default for Model {
102    fn default() -> Self {
103        Model {
104            model_id: 0,
105            slot_id: 0,
106            enabled: false,
107            ordinal: 0,
108            params: vec![]
109        }
110    }
111}
112
113impl Default for ModelParam {
114    fn default() -> Self {
115        ModelParam {
116            param_id: 0,
117            value: Value::Int(0)
118        }
119    }
120}
121
122impl Display for Value {
123    fn fmt(&self, f: &mut Formatter<'_>) -> Result {
124        match self {
125            Value::Int(v) => write!(f, "int {}", v),
126            Value::Float(v) => write!(f, "float {}", v)
127        }
128    }
129}