wled_json_api_library/structures/cfg/
mod.rs1use serde;
2use serde::{Serialize, Deserialize};
3use crate::errors::WledJsonApiError;
4use crate::structures::cfg::cfg_ap::Ap;
5use crate::structures::cfg::cfg_def::Def;
6use crate::structures::cfg::cfg_dmx::Dmx;
7use crate::structures::cfg::cfg_eth::Eth;
8use crate::structures::cfg::cfg_hw::Hw;
9use crate::structures::cfg::cfg_id::Id;
10use crate::structures::cfg::cfg_if2::If2;
11use crate::structures::cfg::cfg_light::Light;
12use crate::structures::cfg::cfg_nw::Nw;
13use crate::structures::cfg::cfg_ol::Ol;
14use crate::structures::cfg::cfg_ota::Ota;
15use crate::structures::cfg::cfg_remote::Remote;
16use crate::structures::cfg::cfg_timers::Timers;
17use crate::structures::cfg::cfg_wifi::Wifi;
18use crate::structures::none_function;
19
20
21
22
23pub mod cfg_id;
24pub mod cfg_nw;
25pub mod cfg_ap;
26pub mod cfg_eth;
27pub mod cfg_wifi;
28pub mod cfg_hw;
29pub mod cfg_light;
30pub mod cfg_def;
31pub mod cfg_if2;
32pub mod cfg_remote;
33pub mod cfg_ol;
34pub mod cfg_timers;
35pub mod cfg_ota;
36pub mod cfg_dmx;
37
38
39#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
40#[serde(rename_all = "camelCase")]
41pub struct Cfg {
42 #[serde(skip_serializing_if = "Option::is_none")]
44 #[serde(default = "none_function")]
45 pub rev: Option<Vec<u32>>,
46
47 #[serde(skip_serializing_if = "Option::is_none")]
49 #[serde(default = "none_function")]
50 pub vid: Option<u64>,
51
52 #[serde(skip_serializing_if = "Option::is_none")]
54 #[serde(default = "none_function")]
55 pub id: Option<Id>,
56
57 #[serde(skip_serializing_if = "Option::is_none")]
59 #[serde(default = "none_function")]
60 pub nw: Option<Nw>,
61
62 #[serde(skip_serializing_if = "Option::is_none")]
64 #[serde(default = "none_function")]
65 pub eth: Option<Eth>,
66
67 #[serde(skip_serializing_if = "Option::is_none")]
69 #[serde(default = "none_function")]
70 pub ap: Option<Ap>,
71
72 #[serde(skip_serializing_if = "Option::is_none")]
74 #[serde(default = "none_function")]
75 pub wifi: Option<Wifi>,
76
77 #[serde(skip_serializing_if = "Option::is_none")]
79 #[serde(default = "none_function")]
80 pub hw: Option<Hw>,
81
82 #[serde(skip_serializing_if = "Option::is_none")]
84 #[serde(default = "none_function")]
85 pub light: Option<Light>,
86
87 #[serde(skip_serializing_if = "Option::is_none")]
89 #[serde(default = "none_function")]
90 pub def: Option<Def>,
91
92 #[serde(skip_serializing_if = "Option::is_none")]
94 #[serde(default = "none_function")]
95 #[serde(rename = "if")]
96 pub if_field: Option<If2>,
97
98 #[serde(skip_serializing_if = "Option::is_none")]
100 #[serde(default = "none_function")]
101 pub remote: Option<Remote>,
102
103 #[serde(skip_serializing_if = "Option::is_none")]
105 #[serde(default = "none_function")]
106 pub ol: Option<Ol>,
107
108 #[serde(skip_serializing_if = "Option::is_none")]
110 #[serde(default = "none_function")]
111 pub timers: Option<Timers>,
112
113 #[serde(skip_serializing_if = "Option::is_none")]
115 #[serde(default = "none_function")]
116 pub ota: Option<Ota>,
117
118 #[serde(skip_serializing_if = "Option::is_none")]
120 #[serde(default = "none_function")]
121 pub dmx: Option<Dmx>,
122
123 #[serde(skip_serializing_if = "Option::is_none")]
125 #[serde(default = "none_function")]
126 pub um: Option<serde_json::Value>,
127}
128
129
130impl TryFrom<&str> for Cfg{
131 type Error = WledJsonApiError;
132 fn try_from(str_in: &str) -> Result<Cfg, WledJsonApiError> {
133 serde_json::from_str(str_in).map_err(|e| {WledJsonApiError::SerdeError(e)})
134 }
135}
136
137impl TryInto<String> for &Cfg{
138 type Error = WledJsonApiError;
139 fn try_into(self) -> Result<String, WledJsonApiError> {
140 serde_json::to_string(self).map_err(|e| {WledJsonApiError::SerdeError(e)})
141 }
142}