plex_api/media_container/preferences/
mod.rs

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