1use crate::format::{CharFormat, CharValue};
5use crate::generated::{CharacteristicType, ServiceType};
6use crate::perms::Perms;
7use serde::Deserialize;
8
9#[derive(Debug, Clone, PartialEq)]
11pub struct Accessory {
12 pub aid: u64,
14 pub services: Vec<Service>,
16}
17
18#[derive(Debug, Clone, PartialEq)]
20pub struct Service {
21 pub iid: u64,
23 pub service_type: ServiceType,
25 pub characteristics: Vec<Characteristic>,
27}
28
29#[derive(Debug, Clone, PartialEq)]
31pub struct Characteristic {
32 pub iid: u64,
34 pub char_type: CharacteristicType,
36 pub format: CharFormat,
38 pub perms: Perms,
40 pub value: Option<CharValue>,
43 pub unit: Option<String>,
45 pub min_value: Option<f64>,
47 pub max_value: Option<f64>,
49 pub min_step: Option<f64>,
51 pub max_len: Option<u64>,
53}
54
55#[derive(Debug, Deserialize)]
58pub(crate) struct WireAccessories {
59 pub accessories: Vec<WireAccessory>,
60}
61
62#[derive(Debug, Deserialize)]
63pub(crate) struct WireAccessory {
64 pub aid: u64,
65 pub services: Vec<WireService>,
66}
67
68#[derive(Debug, Deserialize)]
69pub(crate) struct WireService {
70 pub iid: u64,
71 #[serde(rename = "type")]
72 pub type_: crate::uuid::Uuid,
73 pub characteristics: Vec<WireCharacteristic>,
74}
75
76#[derive(Debug, Deserialize)]
77pub(crate) struct WireCharacteristic {
78 pub iid: u64,
79 #[serde(rename = "type")]
80 pub type_: crate::uuid::Uuid,
81 pub format: CharFormat,
82 pub perms: Perms,
83 #[serde(default)]
84 pub value: Option<serde_json::Value>,
85 #[serde(default)]
86 pub unit: Option<String>,
87 #[serde(default, rename = "minValue")]
88 pub min_value: Option<f64>,
89 #[serde(default, rename = "maxValue")]
90 pub max_value: Option<f64>,
91 #[serde(default, rename = "minStep")]
92 pub min_step: Option<f64>,
93 #[serde(default, rename = "maxLen")]
94 pub max_len: Option<u64>,
95}