1#![allow(unused_qualifications)]
2
3use crate::models;
4#[cfg(any(feature = "client", feature = "server"))]
5use crate::header;
6
7
8#[derive(Debug, Clone, PartialEq, PartialOrd, serde::Serialize, serde::Deserialize)]
10#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
11pub struct Addr(i32);
12
13impl std::convert::From<i32> for Addr {
14 fn from(x: i32) -> Self {
15 Addr(x)
16 }
17}
18
19
20impl std::convert::From<Addr> for i32 {
21 fn from(x: Addr) -> Self {
22 x.0
23 }
24}
25
26impl std::ops::Deref for Addr {
27 type Target = i32;
28 fn deref(&self) -> &i32 {
29 &self.0
30 }
31}
32
33impl std::ops::DerefMut for Addr {
34 fn deref_mut(&mut self) -> &mut i32 {
35 &mut self.0
36 }
37}
38
39
40
41#[derive(Debug, Clone, PartialEq, PartialOrd, serde::Serialize, serde::Deserialize)]
43#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
44pub struct AddrEnabled(bool);
45
46impl std::convert::From<bool> for AddrEnabled {
47 fn from(x: bool) -> Self {
48 AddrEnabled(x)
49 }
50}
51
52
53impl std::convert::From<AddrEnabled> for bool {
54 fn from(x: AddrEnabled) -> Self {
55 x.0
56 }
57}
58
59impl std::ops::Deref for AddrEnabled {
60 type Target = bool;
61 fn deref(&self) -> &bool {
62 &self.0
63 }
64}
65
66impl std::ops::DerefMut for AddrEnabled {
67 fn deref_mut(&mut self) -> &mut bool {
68 &mut self.0
69 }
70}
71
72
73
74#[derive(Debug, Clone, PartialEq, PartialOrd, serde::Serialize, serde::Deserialize)]
76#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
77pub struct AddrIndex(i32);
78
79impl std::convert::From<i32> for AddrIndex {
80 fn from(x: i32) -> Self {
81 AddrIndex(x)
82 }
83}
84
85
86impl std::convert::From<AddrIndex> for i32 {
87 fn from(x: AddrIndex) -> Self {
88 x.0
89 }
90}
91
92impl std::ops::Deref for AddrIndex {
93 type Target = i32;
94 fn deref(&self) -> &i32 {
95 &self.0
96 }
97}
98
99impl std::ops::DerefMut for AddrIndex {
100 fn deref_mut(&mut self) -> &mut i32 {
101 &mut self.0
102 }
103}
104
105
106
107#[cfg(any(feature = "client", feature = "server"))]
111impl std::convert::TryFrom<header::IntoHeaderValue<AddrInfo>> for hyper::header::HeaderValue {
112 type Error = String;
113
114 fn try_from(hdr_value: header::IntoHeaderValue<AddrInfo>) -> std::result::Result<Self, Self::Error> {
115 let hdr_value = hdr_value.to_string();
116 match hyper::header::HeaderValue::from_str(&hdr_value) {
117 std::result::Result::Ok(value) => std::result::Result::Ok(value),
118 std::result::Result::Err(e) => std::result::Result::Err(
119 format!("Invalid header value for AddrInfo - value: {} is invalid {}",
120 hdr_value, e))
121 }
122 }
123}
124
125#[cfg(any(feature = "client", feature = "server"))]
126impl std::convert::TryFrom<hyper::header::HeaderValue> for header::IntoHeaderValue<AddrInfo> {
127 type Error = String;
128
129 fn try_from(hdr_value: hyper::header::HeaderValue) -> std::result::Result<Self, Self::Error> {
130 match hdr_value.to_str() {
131 std::result::Result::Ok(value) => {
132 match <AddrInfo as std::str::FromStr>::from_str(value) {
133 std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)),
134 std::result::Result::Err(err) => std::result::Result::Err(
135 format!("Unable to convert header value '{}' into AddrInfo - {}",
136 value, err))
137 }
138 },
139 std::result::Result::Err(e) => std::result::Result::Err(
140 format!("Unable to convert header: {:?} to string: {}",
141 hdr_value, e))
142 }
143 }
144}
145
146
147#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
148#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
149pub struct AddrInfo {
150 #[serde(rename = "index")]
152 #[serde(skip_serializing_if="Option::is_none")]
153 pub index: Option<u32>,
154
155 #[serde(rename = "enabled")]
157 #[serde(skip_serializing_if="Option::is_none")]
158 pub enabled: Option<bool>,
159
160 #[serde(rename = "addr")]
162 #[serde(skip_serializing_if="Option::is_none")]
163 pub addr: Option<u32>,
164
165}
166
167impl AddrInfo {
168 pub fn new() -> AddrInfo {
169 AddrInfo {
170 index: None,
171 enabled: None,
172 addr: None,
173 }
174 }
175}
176
177impl std::string::ToString for AddrInfo {
181 fn to_string(&self) -> String {
182 let mut params: Vec<String> = vec![];
183
184 if let Some(ref index) = self.index {
185 params.push("index".to_string());
186 params.push(index.to_string());
187 }
188
189
190 if let Some(ref enabled) = self.enabled {
191 params.push("enabled".to_string());
192 params.push(enabled.to_string());
193 }
194
195
196 if let Some(ref addr) = self.addr {
197 params.push("addr".to_string());
198 params.push(addr.to_string());
199 }
200
201 params.join(",").to_string()
202 }
203}
204
205impl std::str::FromStr for AddrInfo {
209 type Err = String;
210
211 fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
212 #[derive(Default)]
213 struct IntermediateRep {
215 pub index: Vec<u32>,
216 pub enabled: Vec<bool>,
217 pub addr: Vec<u32>,
218 }
219
220 let mut intermediate_rep = IntermediateRep::default();
221
222 let mut string_iter = s.split(',').into_iter();
224 let mut key_result = string_iter.next();
225
226 while key_result.is_some() {
227 let val = match string_iter.next() {
228 Some(x) => x,
229 None => return std::result::Result::Err("Missing value while parsing AddrInfo".to_string())
230 };
231
232 if let Some(key) = key_result {
233 match key {
234 "index" => intermediate_rep.index.push(u32::from_str(val).map_err(|x| format!("{}", x))?),
235 "enabled" => intermediate_rep.enabled.push(bool::from_str(val).map_err(|x| format!("{}", x))?),
236 "addr" => intermediate_rep.addr.push(u32::from_str(val).map_err(|x| format!("{}", x))?),
237 _ => return std::result::Result::Err("Unexpected key while parsing AddrInfo".to_string())
238 }
239 }
240
241 key_result = string_iter.next();
243 }
244
245 std::result::Result::Ok(AddrInfo {
247 index: intermediate_rep.index.into_iter().next(),
248 enabled: intermediate_rep.enabled.into_iter().next(),
249 addr: intermediate_rep.addr.into_iter().next(),
250 })
251 }
252}
253
254
255
256#[derive(Debug, Clone, PartialEq, PartialOrd, serde::Serialize, serde::Deserialize)]
258#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
259pub struct ApiError(String);
260
261impl std::convert::From<String> for ApiError {
262 fn from(x: String) -> Self {
263 ApiError(x)
264 }
265}
266
267impl std::string::ToString for ApiError {
268 fn to_string(&self) -> String {
269 self.0.to_string()
270 }
271}
272
273impl std::str::FromStr for ApiError {
274 type Err = std::string::ParseError;
275 fn from_str(x: &str) -> std::result::Result<Self, Self::Err> {
276 std::result::Result::Ok(ApiError(x.to_string()))
277 }
278}
279
280impl std::convert::From<ApiError> for String {
281 fn from(x: ApiError) -> Self {
282 x.0
283 }
284}
285
286impl std::ops::Deref for ApiError {
287 type Target = String;
288 fn deref(&self) -> &String {
289 &self.0
290 }
291}
292
293impl std::ops::DerefMut for ApiError {
294 fn deref_mut(&mut self) -> &mut String {
295 &mut self.0
296 }
297}
298
299
300
301#[cfg(any(feature = "client", feature = "server"))]
305impl std::convert::TryFrom<header::IntoHeaderValue<BadRequest>> for hyper::header::HeaderValue {
306 type Error = String;
307
308 fn try_from(hdr_value: header::IntoHeaderValue<BadRequest>) -> std::result::Result<Self, Self::Error> {
309 let hdr_value = hdr_value.to_string();
310 match hyper::header::HeaderValue::from_str(&hdr_value) {
311 std::result::Result::Ok(value) => std::result::Result::Ok(value),
312 std::result::Result::Err(e) => std::result::Result::Err(
313 format!("Invalid header value for BadRequest - value: {} is invalid {}",
314 hdr_value, e))
315 }
316 }
317}
318
319#[cfg(any(feature = "client", feature = "server"))]
320impl std::convert::TryFrom<hyper::header::HeaderValue> for header::IntoHeaderValue<BadRequest> {
321 type Error = String;
322
323 fn try_from(hdr_value: hyper::header::HeaderValue) -> std::result::Result<Self, Self::Error> {
324 match hdr_value.to_str() {
325 std::result::Result::Ok(value) => {
326 match <BadRequest as std::str::FromStr>::from_str(value) {
327 std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)),
328 std::result::Result::Err(err) => std::result::Result::Err(
329 format!("Unable to convert header value '{}' into BadRequest - {}",
330 value, err))
331 }
332 },
333 std::result::Result::Err(e) => std::result::Result::Err(
334 format!("Unable to convert header: {:?} to string: {}",
335 hdr_value, e))
336 }
337 }
338}
339
340
341#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
342#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
343pub struct BadRequest {
344 #[serde(rename = "parameter")]
346 #[serde(skip_serializing_if="Option::is_none")]
347 pub parameter: Option<String>,
348
349 #[serde(rename = "error")]
351 #[serde(skip_serializing_if="Option::is_none")]
352 pub error: Option<String>,
353
354}
355
356impl BadRequest {
357 pub fn new() -> BadRequest {
358 BadRequest {
359 parameter: None,
360 error: None,
361 }
362 }
363}
364
365impl std::string::ToString for BadRequest {
369 fn to_string(&self) -> String {
370 let mut params: Vec<String> = vec![];
371
372 if let Some(ref parameter) = self.parameter {
373 params.push("parameter".to_string());
374 params.push(parameter.to_string());
375 }
376
377
378 if let Some(ref error) = self.error {
379 params.push("error".to_string());
380 params.push(error.to_string());
381 }
382
383 params.join(",").to_string()
384 }
385}
386
387impl std::str::FromStr for BadRequest {
391 type Err = String;
392
393 fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
394 #[derive(Default)]
395 struct IntermediateRep {
397 pub parameter: Vec<String>,
398 pub error: Vec<String>,
399 }
400
401 let mut intermediate_rep = IntermediateRep::default();
402
403 let mut string_iter = s.split(',').into_iter();
405 let mut key_result = string_iter.next();
406
407 while key_result.is_some() {
408 let val = match string_iter.next() {
409 Some(x) => x,
410 None => return std::result::Result::Err("Missing value while parsing BadRequest".to_string())
411 };
412
413 if let Some(key) = key_result {
414 match key {
415 "parameter" => intermediate_rep.parameter.push(String::from_str(val).map_err(|x| format!("{}", x))?),
416 "error" => intermediate_rep.error.push(String::from_str(val).map_err(|x| format!("{}", x))?),
417 _ => return std::result::Result::Err("Unexpected key while parsing BadRequest".to_string())
418 }
419 }
420
421 key_result = string_iter.next();
423 }
424
425 std::result::Result::Ok(BadRequest {
427 parameter: intermediate_rep.parameter.into_iter().next(),
428 error: intermediate_rep.error.into_iter().next(),
429 })
430 }
431}
432
433
434
435#[derive(Debug, Clone, PartialEq, PartialOrd, serde::Serialize, serde::Deserialize)]
437#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
438pub struct BusId(i32);
439
440impl std::convert::From<i32> for BusId {
441 fn from(x: i32) -> Self {
442 BusId(x)
443 }
444}
445
446
447impl std::convert::From<BusId> for i32 {
448 fn from(x: BusId) -> Self {
449 x.0
450 }
451}
452
453impl std::ops::Deref for BusId {
454 type Target = i32;
455 fn deref(&self) -> &i32 {
456 &self.0
457 }
458}
459
460impl std::ops::DerefMut for BusId {
461 fn deref_mut(&mut self) -> &mut i32 {
462 &mut self.0
463 }
464}
465
466
467
468#[cfg(any(feature = "client", feature = "server"))]
472impl std::convert::TryFrom<header::IntoHeaderValue<Config>> for hyper::header::HeaderValue {
473 type Error = String;
474
475 fn try_from(hdr_value: header::IntoHeaderValue<Config>) -> std::result::Result<Self, Self::Error> {
476 let hdr_value = hdr_value.to_string();
477 match hyper::header::HeaderValue::from_str(&hdr_value) {
478 std::result::Result::Ok(value) => std::result::Result::Ok(value),
479 std::result::Result::Err(e) => std::result::Result::Err(
480 format!("Invalid header value for Config - value: {} is invalid {}",
481 hdr_value, e))
482 }
483 }
484}
485
486#[cfg(any(feature = "client", feature = "server"))]
487impl std::convert::TryFrom<hyper::header::HeaderValue> for header::IntoHeaderValue<Config> {
488 type Error = String;
489
490 fn try_from(hdr_value: hyper::header::HeaderValue) -> std::result::Result<Self, Self::Error> {
491 match hdr_value.to_str() {
492 std::result::Result::Ok(value) => {
493 match <Config as std::str::FromStr>::from_str(value) {
494 std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)),
495 std::result::Result::Err(err) => std::result::Result::Err(
496 format!("Unable to convert header value '{}' into Config - {}",
497 value, err))
498 }
499 },
500 std::result::Result::Err(e) => std::result::Result::Err(
501 format!("Unable to convert header: {:?} to string: {}",
502 hdr_value, e))
503 }
504 }
505}
506
507
508#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
509#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
510pub struct Config {
511 #[serde(rename = "sleep")]
513 #[serde(skip_serializing_if="Option::is_none")]
514 pub sleep: Option<bool>,
515
516 #[serde(rename = "group")]
517 #[serde(skip_serializing_if="Option::is_none")]
518 pub group: Option<models::Group>,
519
520 #[serde(rename = "outputChange")]
521 #[serde(skip_serializing_if="Option::is_none")]
522 pub output_change: Option<models::OutputChange>,
523
524 #[serde(rename = "pwm")]
526 #[serde(skip_serializing_if="Option::is_none")]
527 pub pwm: Option<u32>,
528
529 #[serde(rename = "freq")]
531 #[serde(skip_serializing_if="Option::is_none")]
532 pub freq: Option<u32>,
533
534 #[serde(rename = "offset")]
536 #[serde(skip_serializing_if="Option::is_none")]
537 pub offset: Option<u32>,
538
539 #[serde(rename = "current")]
541 #[serde(skip_serializing_if="Option::is_none")]
542 pub current: Option<u32>,
543
544 #[serde(rename = "addr")]
545 #[serde(skip_serializing_if="Option::is_none")]
546 pub addr: Option<Vec<models::AddrInfo>>,
547
548}
549
550impl Config {
551 pub fn new() -> Config {
552 Config {
553 sleep: None,
554 group: None,
555 output_change: None,
556 pwm: None,
557 freq: None,
558 offset: None,
559 current: None,
560 addr: None,
561 }
562 }
563}
564
565impl std::string::ToString for Config {
569 fn to_string(&self) -> String {
570 let mut params: Vec<String> = vec![];
571
572 if let Some(ref sleep) = self.sleep {
573 params.push("sleep".to_string());
574 params.push(sleep.to_string());
575 }
576
577 if let Some(ref pwm) = self.pwm {
583 params.push("pwm".to_string());
584 params.push(pwm.to_string());
585 }
586
587
588 if let Some(ref freq) = self.freq {
589 params.push("freq".to_string());
590 params.push(freq.to_string());
591 }
592
593
594 if let Some(ref offset) = self.offset {
595 params.push("offset".to_string());
596 params.push(offset.to_string());
597 }
598
599
600 if let Some(ref current) = self.current {
601 params.push("current".to_string());
602 params.push(current.to_string());
603 }
604
605 params.join(",").to_string()
608 }
609}
610
611impl std::str::FromStr for Config {
615 type Err = String;
616
617 fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
618 #[derive(Default)]
619 struct IntermediateRep {
621 pub sleep: Vec<bool>,
622 pub group: Vec<models::Group>,
623 pub output_change: Vec<models::OutputChange>,
624 pub pwm: Vec<u32>,
625 pub freq: Vec<u32>,
626 pub offset: Vec<u32>,
627 pub current: Vec<u32>,
628 pub addr: Vec<Vec<models::AddrInfo>>,
629 }
630
631 let mut intermediate_rep = IntermediateRep::default();
632
633 let mut string_iter = s.split(',').into_iter();
635 let mut key_result = string_iter.next();
636
637 while key_result.is_some() {
638 let val = match string_iter.next() {
639 Some(x) => x,
640 None => return std::result::Result::Err("Missing value while parsing Config".to_string())
641 };
642
643 if let Some(key) = key_result {
644 match key {
645 "sleep" => intermediate_rep.sleep.push(bool::from_str(val).map_err(|x| format!("{}", x))?),
646 "group" => intermediate_rep.group.push(models::Group::from_str(val).map_err(|x| format!("{}", x))?),
647 "outputChange" => intermediate_rep.output_change.push(models::OutputChange::from_str(val).map_err(|x| format!("{}", x))?),
648 "pwm" => intermediate_rep.pwm.push(u32::from_str(val).map_err(|x| format!("{}", x))?),
649 "freq" => intermediate_rep.freq.push(u32::from_str(val).map_err(|x| format!("{}", x))?),
650 "offset" => intermediate_rep.offset.push(u32::from_str(val).map_err(|x| format!("{}", x))?),
651 "current" => intermediate_rep.current.push(u32::from_str(val).map_err(|x| format!("{}", x))?),
652 "addr" => return std::result::Result::Err("Parsing a container in this style is not supported in Config".to_string()),
653 _ => return std::result::Result::Err("Unexpected key while parsing Config".to_string())
654 }
655 }
656
657 key_result = string_iter.next();
659 }
660
661 std::result::Result::Ok(Config {
663 sleep: intermediate_rep.sleep.into_iter().next(),
664 group: intermediate_rep.group.into_iter().next(),
665 output_change: intermediate_rep.output_change.into_iter().next(),
666 pwm: intermediate_rep.pwm.into_iter().next(),
667 freq: intermediate_rep.freq.into_iter().next(),
668 offset: intermediate_rep.offset.into_iter().next(),
669 current: intermediate_rep.current.into_iter().next(),
670 addr: intermediate_rep.addr.into_iter().next(),
671 })
672 }
673}
674
675
676
677#[derive(Debug, Clone, PartialEq, PartialOrd, serde::Serialize, serde::Deserialize)]
679#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
680pub struct Current(i32);
681
682impl std::convert::From<i32> for Current {
683 fn from(x: i32) -> Self {
684 Current(x)
685 }
686}
687
688
689impl std::convert::From<Current> for i32 {
690 fn from(x: Current) -> Self {
691 x.0
692 }
693}
694
695impl std::ops::Deref for Current {
696 type Target = i32;
697 fn deref(&self) -> &i32 {
698 &self.0
699 }
700}
701
702impl std::ops::DerefMut for Current {
703 fn deref_mut(&mut self) -> &mut i32 {
704 &mut self.0
705 }
706}
707
708
709
710#[derive(Debug, Clone, PartialEq, PartialOrd, serde::Serialize, serde::Deserialize)]
712#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
713pub struct Error(bool);
714
715impl std::convert::From<bool> for Error {
716 fn from(x: bool) -> Self {
717 Error(x)
718 }
719}
720
721
722impl std::convert::From<Error> for bool {
723 fn from(x: Error) -> Self {
724 x.0
725 }
726}
727
728impl std::ops::Deref for Error {
729 type Target = bool;
730 fn deref(&self) -> &bool {
731 &self.0
732 }
733}
734
735impl std::ops::DerefMut for Error {
736 fn deref_mut(&mut self) -> &mut bool {
737 &mut self.0
738 }
739}
740
741
742
743#[derive(Debug, Clone, PartialEq, PartialOrd, serde::Serialize, serde::Deserialize)]
745#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
746pub struct Freq(i32);
747
748impl std::convert::From<i32> for Freq {
749 fn from(x: i32) -> Self {
750 Freq(x)
751 }
752}
753
754
755impl std::convert::From<Freq> for i32 {
756 fn from(x: Freq) -> Self {
757 x.0
758 }
759}
760
761impl std::ops::Deref for Freq {
762 type Target = i32;
763 fn deref(&self) -> &i32 {
764 &self.0
765 }
766}
767
768impl std::ops::DerefMut for Freq {
769 fn deref_mut(&mut self) -> &mut i32 {
770 &mut self.0
771 }
772}
773
774
775
776#[allow(non_camel_case_types)]
781#[repr(C)]
782#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, serde::Serialize, serde::Deserialize)]
783#[cfg_attr(feature = "conversion", derive(frunk_enum_derive::LabelledGenericEnum))]
784pub enum Group {
785 #[serde(rename = "dim")]
786 DIM,
787 #[serde(rename = "blink")]
788 BLINK,
789}
790
791impl std::fmt::Display for Group {
792 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
793 match *self {
794 Group::DIM => write!(f, "{}", "dim"),
795 Group::BLINK => write!(f, "{}", "blink"),
796 }
797 }
798}
799
800impl std::str::FromStr for Group {
801 type Err = String;
802
803 fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
804 match s {
805 "dim" => std::result::Result::Ok(Group::DIM),
806 "blink" => std::result::Result::Ok(Group::BLINK),
807 _ => std::result::Result::Err(format!("Value not valid: {}", s)),
808 }
809 }
810}
811
812
813#[allow(non_camel_case_types)]
818#[repr(C)]
819#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, serde::Serialize, serde::Deserialize)]
820#[cfg_attr(feature = "conversion", derive(frunk_enum_derive::LabelledGenericEnum))]
821pub enum LedError {
822 #[serde(rename = "none")]
823 NONE,
824 #[serde(rename = "short")]
825 SHORT,
826 #[serde(rename = "open")]
827 OPEN,
828 #[serde(rename = "dne")]
829 DNE,
830}
831
832impl std::fmt::Display for LedError {
833 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
834 match *self {
835 LedError::NONE => write!(f, "{}", "none"),
836 LedError::SHORT => write!(f, "{}", "short"),
837 LedError::OPEN => write!(f, "{}", "open"),
838 LedError::DNE => write!(f, "{}", "dne"),
839 }
840 }
841}
842
843impl std::str::FromStr for LedError {
844 type Err = String;
845
846 fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
847 match s {
848 "none" => std::result::Result::Ok(LedError::NONE),
849 "short" => std::result::Result::Ok(LedError::SHORT),
850 "open" => std::result::Result::Ok(LedError::OPEN),
851 "dne" => std::result::Result::Ok(LedError::DNE),
852 _ => std::result::Result::Err(format!("Value not valid: {}", s)),
853 }
854 }
855}
856
857
858#[cfg(any(feature = "client", feature = "server"))]
861impl std::convert::TryFrom<header::IntoHeaderValue<LedErrors>> for hyper::header::HeaderValue {
862 type Error = String;
863
864 fn try_from(hdr_value: header::IntoHeaderValue<LedErrors>) -> std::result::Result<Self, Self::Error> {
865 let hdr_value = hdr_value.to_string();
866 match hyper::header::HeaderValue::from_str(&hdr_value) {
867 std::result::Result::Ok(value) => std::result::Result::Ok(value),
868 std::result::Result::Err(e) => std::result::Result::Err(
869 format!("Invalid header value for LedErrors - value: {} is invalid {}",
870 hdr_value, e))
871 }
872 }
873}
874
875#[cfg(any(feature = "client", feature = "server"))]
876impl std::convert::TryFrom<hyper::header::HeaderValue> for header::IntoHeaderValue<LedErrors> {
877 type Error = String;
878
879 fn try_from(hdr_value: hyper::header::HeaderValue) -> std::result::Result<Self, Self::Error> {
880 match hdr_value.to_str() {
881 std::result::Result::Ok(value) => {
882 match <LedErrors as std::str::FromStr>::from_str(value) {
883 std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)),
884 std::result::Result::Err(err) => std::result::Result::Err(
885 format!("Unable to convert header value '{}' into LedErrors - {}",
886 value, err))
887 }
888 },
889 std::result::Result::Err(e) => std::result::Result::Err(
890 format!("Unable to convert header: {:?} to string: {}",
891 hdr_value, e))
892 }
893 }
894}
895
896#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
897#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
898pub struct LedErrors(
899 Vec<AddrInfo>
900);
901
902impl std::convert::From<Vec<AddrInfo>> for LedErrors {
903 fn from(x: Vec<AddrInfo>) -> Self {
904 LedErrors(x)
905 }
906}
907
908impl std::convert::From<LedErrors> for Vec<AddrInfo> {
909 fn from(x: LedErrors) -> Self {
910 x.0
911 }
912}
913
914impl std::iter::FromIterator<AddrInfo> for LedErrors {
915 fn from_iter<U: IntoIterator<Item=AddrInfo>>(u: U) -> Self {
916 LedErrors(Vec::<AddrInfo>::from_iter(u))
917 }
918}
919
920impl std::iter::IntoIterator for LedErrors {
921 type Item = AddrInfo;
922 type IntoIter = std::vec::IntoIter<AddrInfo>;
923
924 fn into_iter(self) -> Self::IntoIter {
925 self.0.into_iter()
926 }
927}
928
929impl<'a> std::iter::IntoIterator for &'a LedErrors {
930 type Item = &'a AddrInfo;
931 type IntoIter = std::slice::Iter<'a, AddrInfo>;
932
933 fn into_iter(self) -> Self::IntoIter {
934 (&self.0).into_iter()
935 }
936}
937
938impl<'a> std::iter::IntoIterator for &'a mut LedErrors {
939 type Item = &'a mut AddrInfo;
940 type IntoIter = std::slice::IterMut<'a, AddrInfo>;
941
942 fn into_iter(self) -> Self::IntoIter {
943 (&mut self.0).into_iter()
944 }
945}
946
947impl std::ops::Deref for LedErrors {
948 type Target = Vec<AddrInfo>;
949 fn deref(&self) -> &Self::Target {
950 &self.0
951 }
952}
953
954impl std::ops::DerefMut for LedErrors {
955 fn deref_mut(&mut self) -> &mut Self::Target {
956 &mut self.0
957 }
958}
959
960impl std::string::ToString for LedErrors {
964 fn to_string(&self) -> String {
965 self.iter().map(|x| x.to_string()).collect::<Vec<_>>().join(",").to_string()
966 }
967}
968
969impl std::str::FromStr for LedErrors {
973 type Err = <AddrInfo as std::str::FromStr>::Err;
974
975 fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
976 let mut items = vec![];
977 for item in s.split(',')
978 {
979 items.push(item.parse()?);
980 }
981 std::result::Result::Ok(LedErrors(items))
982 }
983}
984
985
986
987#[derive(Debug, Clone, PartialEq, PartialOrd, serde::Serialize, serde::Deserialize)]
989#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
990pub struct LedIndex(i32);
991
992impl std::convert::From<i32> for LedIndex {
993 fn from(x: i32) -> Self {
994 LedIndex(x)
995 }
996}
997
998
999impl std::convert::From<LedIndex> for i32 {
1000 fn from(x: LedIndex) -> Self {
1001 x.0
1002 }
1003}
1004
1005impl std::ops::Deref for LedIndex {
1006 type Target = i32;
1007 fn deref(&self) -> &i32 {
1008 &self.0
1009 }
1010}
1011
1012impl std::ops::DerefMut for LedIndex {
1013 fn deref_mut(&mut self) -> &mut i32 {
1014 &mut self.0
1015 }
1016}
1017
1018
1019
1020#[cfg(any(feature = "client", feature = "server"))]
1024impl std::convert::TryFrom<header::IntoHeaderValue<LedInfo>> for hyper::header::HeaderValue {
1025 type Error = String;
1026
1027 fn try_from(hdr_value: header::IntoHeaderValue<LedInfo>) -> std::result::Result<Self, Self::Error> {
1028 let hdr_value = hdr_value.to_string();
1029 match hyper::header::HeaderValue::from_str(&hdr_value) {
1030 std::result::Result::Ok(value) => std::result::Result::Ok(value),
1031 std::result::Result::Err(e) => std::result::Result::Err(
1032 format!("Invalid header value for LedInfo - value: {} is invalid {}",
1033 hdr_value, e))
1034 }
1035 }
1036}
1037
1038#[cfg(any(feature = "client", feature = "server"))]
1039impl std::convert::TryFrom<hyper::header::HeaderValue> for header::IntoHeaderValue<LedInfo> {
1040 type Error = String;
1041
1042 fn try_from(hdr_value: hyper::header::HeaderValue) -> std::result::Result<Self, Self::Error> {
1043 match hdr_value.to_str() {
1044 std::result::Result::Ok(value) => {
1045 match <LedInfo as std::str::FromStr>::from_str(value) {
1046 std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)),
1047 std::result::Result::Err(err) => std::result::Result::Err(
1048 format!("Unable to convert header value '{}' into LedInfo - {}",
1049 value, err))
1050 }
1051 },
1052 std::result::Result::Err(e) => std::result::Result::Err(
1053 format!("Unable to convert header: {:?} to string: {}",
1054 hdr_value, e))
1055 }
1056 }
1057}
1058
1059
1060#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
1061#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
1062pub struct LedInfo {
1063 #[serde(rename = "index")]
1065 #[serde(skip_serializing_if="Option::is_none")]
1066 pub index: Option<u32>,
1067
1068 #[serde(rename = "state")]
1069 #[serde(skip_serializing_if="Option::is_none")]
1070 pub state: Option<models::LedState>,
1071
1072 #[serde(rename = "pwm")]
1074 #[serde(skip_serializing_if="Option::is_none")]
1075 pub pwm: Option<u32>,
1076
1077 #[serde(rename = "current")]
1079 #[serde(skip_serializing_if="Option::is_none")]
1080 pub current: Option<u32>,
1081
1082 #[serde(rename = "error")]
1083 #[serde(skip_serializing_if="Option::is_none")]
1084 pub error: Option<models::LedError>,
1085
1086}
1087
1088impl LedInfo {
1089 pub fn new() -> LedInfo {
1090 LedInfo {
1091 index: None,
1092 state: None,
1093 pwm: None,
1094 current: None,
1095 error: None,
1096 }
1097 }
1098}
1099
1100impl std::string::ToString for LedInfo {
1104 fn to_string(&self) -> String {
1105 let mut params: Vec<String> = vec![];
1106
1107 if let Some(ref index) = self.index {
1108 params.push("index".to_string());
1109 params.push(index.to_string());
1110 }
1111
1112 if let Some(ref pwm) = self.pwm {
1116 params.push("pwm".to_string());
1117 params.push(pwm.to_string());
1118 }
1119
1120
1121 if let Some(ref current) = self.current {
1122 params.push("current".to_string());
1123 params.push(current.to_string());
1124 }
1125
1126 params.join(",").to_string()
1129 }
1130}
1131
1132impl std::str::FromStr for LedInfo {
1136 type Err = String;
1137
1138 fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
1139 #[derive(Default)]
1140 struct IntermediateRep {
1142 pub index: Vec<u32>,
1143 pub state: Vec<models::LedState>,
1144 pub pwm: Vec<u32>,
1145 pub current: Vec<u32>,
1146 pub error: Vec<models::LedError>,
1147 }
1148
1149 let mut intermediate_rep = IntermediateRep::default();
1150
1151 let mut string_iter = s.split(',').into_iter();
1153 let mut key_result = string_iter.next();
1154
1155 while key_result.is_some() {
1156 let val = match string_iter.next() {
1157 Some(x) => x,
1158 None => return std::result::Result::Err("Missing value while parsing LedInfo".to_string())
1159 };
1160
1161 if let Some(key) = key_result {
1162 match key {
1163 "index" => intermediate_rep.index.push(u32::from_str(val).map_err(|x| format!("{}", x))?),
1164 "state" => intermediate_rep.state.push(models::LedState::from_str(val).map_err(|x| format!("{}", x))?),
1165 "pwm" => intermediate_rep.pwm.push(u32::from_str(val).map_err(|x| format!("{}", x))?),
1166 "current" => intermediate_rep.current.push(u32::from_str(val).map_err(|x| format!("{}", x))?),
1167 "error" => intermediate_rep.error.push(models::LedError::from_str(val).map_err(|x| format!("{}", x))?),
1168 _ => return std::result::Result::Err("Unexpected key while parsing LedInfo".to_string())
1169 }
1170 }
1171
1172 key_result = string_iter.next();
1174 }
1175
1176 std::result::Result::Ok(LedInfo {
1178 index: intermediate_rep.index.into_iter().next(),
1179 state: intermediate_rep.state.into_iter().next(),
1180 pwm: intermediate_rep.pwm.into_iter().next(),
1181 current: intermediate_rep.current.into_iter().next(),
1182 error: intermediate_rep.error.into_iter().next(),
1183 })
1184 }
1185}
1186
1187
1188
1189#[cfg(any(feature = "client", feature = "server"))]
1192impl std::convert::TryFrom<header::IntoHeaderValue<LedInfoArray>> for hyper::header::HeaderValue {
1193 type Error = String;
1194
1195 fn try_from(hdr_value: header::IntoHeaderValue<LedInfoArray>) -> std::result::Result<Self, Self::Error> {
1196 let hdr_value = hdr_value.to_string();
1197 match hyper::header::HeaderValue::from_str(&hdr_value) {
1198 std::result::Result::Ok(value) => std::result::Result::Ok(value),
1199 std::result::Result::Err(e) => std::result::Result::Err(
1200 format!("Invalid header value for LedInfoArray - value: {} is invalid {}",
1201 hdr_value, e))
1202 }
1203 }
1204}
1205
1206#[cfg(any(feature = "client", feature = "server"))]
1207impl std::convert::TryFrom<hyper::header::HeaderValue> for header::IntoHeaderValue<LedInfoArray> {
1208 type Error = String;
1209
1210 fn try_from(hdr_value: hyper::header::HeaderValue) -> std::result::Result<Self, Self::Error> {
1211 match hdr_value.to_str() {
1212 std::result::Result::Ok(value) => {
1213 match <LedInfoArray as std::str::FromStr>::from_str(value) {
1214 std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)),
1215 std::result::Result::Err(err) => std::result::Result::Err(
1216 format!("Unable to convert header value '{}' into LedInfoArray - {}",
1217 value, err))
1218 }
1219 },
1220 std::result::Result::Err(e) => std::result::Result::Err(
1221 format!("Unable to convert header: {:?} to string: {}",
1222 hdr_value, e))
1223 }
1224 }
1225}
1226
1227#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
1228#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
1229pub struct LedInfoArray(
1230 Vec<LedInfo>
1231);
1232
1233impl std::convert::From<Vec<LedInfo>> for LedInfoArray {
1234 fn from(x: Vec<LedInfo>) -> Self {
1235 LedInfoArray(x)
1236 }
1237}
1238
1239impl std::convert::From<LedInfoArray> for Vec<LedInfo> {
1240 fn from(x: LedInfoArray) -> Self {
1241 x.0
1242 }
1243}
1244
1245impl std::iter::FromIterator<LedInfo> for LedInfoArray {
1246 fn from_iter<U: IntoIterator<Item=LedInfo>>(u: U) -> Self {
1247 LedInfoArray(Vec::<LedInfo>::from_iter(u))
1248 }
1249}
1250
1251impl std::iter::IntoIterator for LedInfoArray {
1252 type Item = LedInfo;
1253 type IntoIter = std::vec::IntoIter<LedInfo>;
1254
1255 fn into_iter(self) -> Self::IntoIter {
1256 self.0.into_iter()
1257 }
1258}
1259
1260impl<'a> std::iter::IntoIterator for &'a LedInfoArray {
1261 type Item = &'a LedInfo;
1262 type IntoIter = std::slice::Iter<'a, LedInfo>;
1263
1264 fn into_iter(self) -> Self::IntoIter {
1265 (&self.0).into_iter()
1266 }
1267}
1268
1269impl<'a> std::iter::IntoIterator for &'a mut LedInfoArray {
1270 type Item = &'a mut LedInfo;
1271 type IntoIter = std::slice::IterMut<'a, LedInfo>;
1272
1273 fn into_iter(self) -> Self::IntoIter {
1274 (&mut self.0).into_iter()
1275 }
1276}
1277
1278impl std::ops::Deref for LedInfoArray {
1279 type Target = Vec<LedInfo>;
1280 fn deref(&self) -> &Self::Target {
1281 &self.0
1282 }
1283}
1284
1285impl std::ops::DerefMut for LedInfoArray {
1286 fn deref_mut(&mut self) -> &mut Self::Target {
1287 &mut self.0
1288 }
1289}
1290
1291impl std::string::ToString for LedInfoArray {
1295 fn to_string(&self) -> String {
1296 self.iter().map(|x| x.to_string()).collect::<Vec<_>>().join(",").to_string()
1297 }
1298}
1299
1300impl std::str::FromStr for LedInfoArray {
1304 type Err = <LedInfo as std::str::FromStr>::Err;
1305
1306 fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
1307 let mut items = vec![];
1308 for item in s.split(',')
1309 {
1310 items.push(item.parse()?);
1311 }
1312 std::result::Result::Ok(LedInfoArray(items))
1313 }
1314}
1315
1316
1317
1318#[allow(non_camel_case_types)]
1323#[repr(C)]
1324#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, serde::Serialize, serde::Deserialize)]
1325#[cfg_attr(feature = "conversion", derive(frunk_enum_derive::LabelledGenericEnum))]
1326pub enum LedState {
1327 #[serde(rename = "false")]
1328 FALSE,
1329 #[serde(rename = "true")]
1330 TRUE,
1331 #[serde(rename = "pwm")]
1332 PWM,
1333 #[serde(rename = "pwmPlus")]
1334 PWMPLUS,
1335}
1336
1337impl std::fmt::Display for LedState {
1338 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
1339 match *self {
1340 LedState::FALSE => write!(f, "{}", "false"),
1341 LedState::TRUE => write!(f, "{}", "true"),
1342 LedState::PWM => write!(f, "{}", "pwm"),
1343 LedState::PWMPLUS => write!(f, "{}", "pwmPlus"),
1344 }
1345 }
1346}
1347
1348impl std::str::FromStr for LedState {
1349 type Err = String;
1350
1351 fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
1352 match s {
1353 "false" => std::result::Result::Ok(LedState::FALSE),
1354 "true" => std::result::Result::Ok(LedState::TRUE),
1355 "pwm" => std::result::Result::Ok(LedState::PWM),
1356 "pwmPlus" => std::result::Result::Ok(LedState::PWMPLUS),
1357 _ => std::result::Result::Err(format!("Value not valid: {}", s)),
1358 }
1359 }
1360}
1361
1362
1363#[derive(Debug, Clone, PartialEq, PartialOrd, serde::Serialize, serde::Deserialize)]
1365#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
1366pub struct Offset(i32);
1367
1368impl std::convert::From<i32> for Offset {
1369 fn from(x: i32) -> Self {
1370 Offset(x)
1371 }
1372}
1373
1374
1375impl std::convert::From<Offset> for i32 {
1376 fn from(x: Offset) -> Self {
1377 x.0
1378 }
1379}
1380
1381impl std::ops::Deref for Offset {
1382 type Target = i32;
1383 fn deref(&self) -> &i32 {
1384 &self.0
1385 }
1386}
1387
1388impl std::ops::DerefMut for Offset {
1389 fn deref_mut(&mut self) -> &mut i32 {
1390 &mut self.0
1391 }
1392}
1393
1394
1395
1396#[cfg(any(feature = "client", feature = "server"))]
1400impl std::convert::TryFrom<header::IntoHeaderValue<OpError>> for hyper::header::HeaderValue {
1401 type Error = String;
1402
1403 fn try_from(hdr_value: header::IntoHeaderValue<OpError>) -> std::result::Result<Self, Self::Error> {
1404 let hdr_value = hdr_value.to_string();
1405 match hyper::header::HeaderValue::from_str(&hdr_value) {
1406 std::result::Result::Ok(value) => std::result::Result::Ok(value),
1407 std::result::Result::Err(e) => std::result::Result::Err(
1408 format!("Invalid header value for OpError - value: {} is invalid {}",
1409 hdr_value, e))
1410 }
1411 }
1412}
1413
1414#[cfg(any(feature = "client", feature = "server"))]
1415impl std::convert::TryFrom<hyper::header::HeaderValue> for header::IntoHeaderValue<OpError> {
1416 type Error = String;
1417
1418 fn try_from(hdr_value: hyper::header::HeaderValue) -> std::result::Result<Self, Self::Error> {
1419 match hdr_value.to_str() {
1420 std::result::Result::Ok(value) => {
1421 match <OpError as std::str::FromStr>::from_str(value) {
1422 std::result::Result::Ok(value) => std::result::Result::Ok(header::IntoHeaderValue(value)),
1423 std::result::Result::Err(err) => std::result::Result::Err(
1424 format!("Unable to convert header value '{}' into OpError - {}",
1425 value, err))
1426 }
1427 },
1428 std::result::Result::Err(e) => std::result::Result::Err(
1429 format!("Unable to convert header: {:?} to string: {}",
1430 hdr_value, e))
1431 }
1432 }
1433}
1434
1435
1436#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
1437#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
1438pub struct OpError {
1439 #[serde(rename = "error")]
1441 #[serde(skip_serializing_if="Option::is_none")]
1442 pub error: Option<String>,
1443
1444}
1445
1446impl OpError {
1447 pub fn new() -> OpError {
1448 OpError {
1449 error: None,
1450 }
1451 }
1452}
1453
1454impl std::string::ToString for OpError {
1458 fn to_string(&self) -> String {
1459 let mut params: Vec<String> = vec![];
1460
1461 if let Some(ref error) = self.error {
1462 params.push("error".to_string());
1463 params.push(error.to_string());
1464 }
1465
1466 params.join(",").to_string()
1467 }
1468}
1469
1470impl std::str::FromStr for OpError {
1474 type Err = String;
1475
1476 fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
1477 #[derive(Default)]
1478 struct IntermediateRep {
1480 pub error: Vec<String>,
1481 }
1482
1483 let mut intermediate_rep = IntermediateRep::default();
1484
1485 let mut string_iter = s.split(',').into_iter();
1487 let mut key_result = string_iter.next();
1488
1489 while key_result.is_some() {
1490 let val = match string_iter.next() {
1491 Some(x) => x,
1492 None => return std::result::Result::Err("Missing value while parsing OpError".to_string())
1493 };
1494
1495 if let Some(key) = key_result {
1496 match key {
1497 "error" => intermediate_rep.error.push(String::from_str(val).map_err(|x| format!("{}", x))?),
1498 _ => return std::result::Result::Err("Unexpected key while parsing OpError".to_string())
1499 }
1500 }
1501
1502 key_result = string_iter.next();
1504 }
1505
1506 std::result::Result::Ok(OpError {
1508 error: intermediate_rep.error.into_iter().next(),
1509 })
1510 }
1511}
1512
1513
1514
1515#[allow(non_camel_case_types)]
1520#[repr(C)]
1521#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, serde::Serialize, serde::Deserialize)]
1522#[cfg_attr(feature = "conversion", derive(frunk_enum_derive::LabelledGenericEnum))]
1523pub enum OutputChange {
1524 #[serde(rename = "stop")]
1525 STOP,
1526 #[serde(rename = "ack")]
1527 ACK,
1528}
1529
1530impl std::fmt::Display for OutputChange {
1531 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
1532 match *self {
1533 OutputChange::STOP => write!(f, "{}", "stop"),
1534 OutputChange::ACK => write!(f, "{}", "ack"),
1535 }
1536 }
1537}
1538
1539impl std::str::FromStr for OutputChange {
1540 type Err = String;
1541
1542 fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
1543 match s {
1544 "stop" => std::result::Result::Ok(OutputChange::STOP),
1545 "ack" => std::result::Result::Ok(OutputChange::ACK),
1546 _ => std::result::Result::Err(format!("Value not valid: {}", s)),
1547 }
1548 }
1549}
1550
1551
1552#[derive(Debug, Clone, PartialEq, PartialOrd, serde::Serialize, serde::Deserialize)]
1554#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
1555pub struct OverTemp(bool);
1556
1557impl std::convert::From<bool> for OverTemp {
1558 fn from(x: bool) -> Self {
1559 OverTemp(x)
1560 }
1561}
1562
1563
1564impl std::convert::From<OverTemp> for bool {
1565 fn from(x: OverTemp) -> Self {
1566 x.0
1567 }
1568}
1569
1570impl std::ops::Deref for OverTemp {
1571 type Target = bool;
1572 fn deref(&self) -> &bool {
1573 &self.0
1574 }
1575}
1576
1577impl std::ops::DerefMut for OverTemp {
1578 fn deref_mut(&mut self) -> &mut bool {
1579 &mut self.0
1580 }
1581}
1582
1583
1584
1585#[derive(Debug, Clone, PartialEq, PartialOrd, serde::Serialize, serde::Deserialize)]
1587#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
1588pub struct Pwm(i32);
1589
1590impl std::convert::From<i32> for Pwm {
1591 fn from(x: i32) -> Self {
1592 Pwm(x)
1593 }
1594}
1595
1596
1597impl std::convert::From<Pwm> for i32 {
1598 fn from(x: Pwm) -> Self {
1599 x.0
1600 }
1601}
1602
1603impl std::ops::Deref for Pwm {
1604 type Target = i32;
1605 fn deref(&self) -> &i32 {
1606 &self.0
1607 }
1608}
1609
1610impl std::ops::DerefMut for Pwm {
1611 fn deref_mut(&mut self) -> &mut i32 {
1612 &mut self.0
1613 }
1614}
1615
1616
1617
1618#[derive(Debug, Clone, PartialEq, PartialOrd, serde::Serialize, serde::Deserialize)]
1620#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
1621pub struct Sleep(bool);
1622
1623impl std::convert::From<bool> for Sleep {
1624 fn from(x: bool) -> Self {
1625 Sleep(x)
1626 }
1627}
1628
1629
1630impl std::convert::From<Sleep> for bool {
1631 fn from(x: Sleep) -> Self {
1632 x.0
1633 }
1634}
1635
1636impl std::ops::Deref for Sleep {
1637 type Target = bool;
1638 fn deref(&self) -> &bool {
1639 &self.0
1640 }
1641}
1642
1643impl std::ops::DerefMut for Sleep {
1644 fn deref_mut(&mut self) -> &mut bool {
1645 &mut self.0
1646 }
1647}
1648
1649
1650
1651#[derive(Debug, Clone, PartialEq, PartialOrd, serde::Serialize, serde::Deserialize)]
1653#[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))]
1654pub struct Yaml(String);
1655
1656impl std::convert::From<String> for Yaml {
1657 fn from(x: String) -> Self {
1658 Yaml(x)
1659 }
1660}
1661
1662impl std::string::ToString for Yaml {
1663 fn to_string(&self) -> String {
1664 self.0.to_string()
1665 }
1666}
1667
1668impl std::str::FromStr for Yaml {
1669 type Err = std::string::ParseError;
1670 fn from_str(x: &str) -> std::result::Result<Self, Self::Err> {
1671 std::result::Result::Ok(Yaml(x.to_string()))
1672 }
1673}
1674
1675impl std::convert::From<Yaml> for String {
1676 fn from(x: Yaml) -> Self {
1677 x.0
1678 }
1679}
1680
1681impl std::ops::Deref for Yaml {
1682 type Target = String;
1683 fn deref(&self) -> &String {
1684 &self.0
1685 }
1686}
1687
1688impl std::ops::DerefMut for Yaml {
1689 fn deref_mut(&mut self) -> &mut String {
1690 &mut self.0
1691 }
1692}
1693
1694