1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
mod deserializer;
use super::MediaContainer;
use serde::Deserialize;
#[derive(Debug, Deserialize, Clone)]
#[cfg_attr(
all(test, feature = "tests_deny_unknown_fields"),
serde(deny_unknown_fields)
)]
pub struct Preferences {
#[serde(rename = "Setting", default)]
pub settings: Vec<Setting>,
#[serde(flatten)]
pub media_container: MediaContainer,
}
#[derive(Debug, Clone)]
pub struct Setting {
pub id: String,
pub label: String,
pub summary: String,
pub hidden: bool,
pub advanced: bool,
pub group: String,
pub value: Value,
pub default: Value,
pub suggested_values: Option<Vec<SettingEnumValue>>,
}
#[derive(Debug, Clone)]
pub enum Value {
Int(i64),
Text(String),
Bool(bool),
Double(f64),
}
impl ToString for Value {
fn to_string(&self) -> String {
match self {
Value::Text(s) => s.to_owned(),
Value::Int(i) => i.to_string(),
Value::Bool(b) => (if *b { "1" } else { "0" }).to_owned(),
Value::Double(d) => d.to_string(),
}
}
}
#[derive(Debug, Clone)]
pub struct SettingEnumValue {
pub value: String,
pub hint: String,
}