matter_kit/clusters/generated/
time_format_localization.rs1#![allow(unused_imports)]
15
16use crate::dm::conformance::{Clause, Condition, Conform, Conformance};
17use crate::dm::meta::{EventPriority, Reporting};
18use crate::dm::spec::{Attribute, Cluster, Command, Event, Feature};
19use crate::dm::{Access, AccessQualities, AttributeQualities, Privilege};
20use crate::error::Result;
21use crate::im::{AttributeId, ClusterId, CommandId, EventId};
22use crate::tlv::{
23 ContainerKind, Element, FromTlv, Nullable, Tag, TlvList, TlvReader, TlvWriter, ToTlv, Value,
24};
25
26pub const ID: ClusterId = 0x002C;
28
29pub const REVISION: u16 = 1;
32
33pub const PICS: &str = "LTIME";
35
36pub mod feature {
41 pub const CALENDAR_FORMAT: u32 = 1 << 0;
45}
46
47pub const FEATURES: &[Feature] = &[Feature {
49 bit: 0,
50 code: "CALFMT",
51 name: "CalendarFormat",
52 conform: Conform::OPTIONAL,
53}];
54
55pub mod attribute {
57 use crate::im::AttributeId;
58
59 pub const HOUR_FORMAT: AttributeId = 0x00;
61 pub const ACTIVE_CALENDAR_TYPE: AttributeId = 0x01;
63 pub const SUPPORTED_CALENDAR_TYPES: AttributeId = 0x02;
65}
66
67#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
69#[repr(u8)]
70pub enum CalendarTypeEnum {
71 Buddhist = 0,
73 Chinese = 1,
75 Coptic = 2,
77 Ethiopian = 3,
79 Gregorian = 4,
81 Hebrew = 5,
83 Indian = 6,
85 Islamic = 7,
87 Japanese = 8,
89 Korean = 9,
91 Persian = 10,
93 Taiwanese = 11,
95 UseActiveLocale = 255,
97}
98
99impl CalendarTypeEnum {
100 #[must_use]
102 pub const fn from_value(value: u8) -> Option<Self> {
103 match value {
104 0 => Some(Self::Buddhist),
105 1 => Some(Self::Chinese),
106 2 => Some(Self::Coptic),
107 3 => Some(Self::Ethiopian),
108 4 => Some(Self::Gregorian),
109 5 => Some(Self::Hebrew),
110 6 => Some(Self::Indian),
111 7 => Some(Self::Islamic),
112 8 => Some(Self::Japanese),
113 9 => Some(Self::Korean),
114 10 => Some(Self::Persian),
115 11 => Some(Self::Taiwanese),
116 255 => Some(Self::UseActiveLocale),
117 _ => None,
118 }
119 }
120
121 #[must_use]
123 pub const fn value(self) -> u8 {
124 self as u8
125 }
126}
127
128impl ToTlv for CalendarTypeEnum {
129 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
130 self.value().to_tlv(w, tag)
131 }
132}
133
134impl<'a> FromTlv<'a> for CalendarTypeEnum {
135 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
136 let value = <u8 as FromTlv<'a>>::from_tlv(reader, element)?;
137 Self::from_value(value).ok_or(crate::Error::new(crate::ErrorCode::TlvOutOfRange))
138 }
139}
140
141#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
143#[repr(u8)]
144pub enum HourFormatEnum {
145 N12Hr = 0,
147 N24Hr = 1,
149 UseActiveLocale = 255,
151}
152
153impl HourFormatEnum {
154 #[must_use]
156 pub const fn from_value(value: u8) -> Option<Self> {
157 match value {
158 0 => Some(Self::N12Hr),
159 1 => Some(Self::N24Hr),
160 255 => Some(Self::UseActiveLocale),
161 _ => None,
162 }
163 }
164
165 #[must_use]
167 pub const fn value(self) -> u8 {
168 self as u8
169 }
170}
171
172impl ToTlv for HourFormatEnum {
173 fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
174 self.value().to_tlv(w, tag)
175 }
176}
177
178impl<'a> FromTlv<'a> for HourFormatEnum {
179 fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
180 let value = <u8 as FromTlv<'a>>::from_tlv(reader, element)?;
181 Self::from_value(value).ok_or(crate::Error::new(crate::ErrorCode::TlvOutOfRange))
182 }
183}
184
185pub const ATTRIBUTES: &[Attribute] = &[
187 Attribute {
188 id: 0x0000,
189 name: "HourFormat",
190 kind: "HourFormatEnum",
191 access: Access::read_write_with(Privilege::View, Privilege::Manage),
192 qualities: AttributeQualities::NON_VOLATILE,
193 reporting: Reporting::OnChange,
194 conform: Conform::MANDATORY,
195 },
196 Attribute {
197 id: 0x0001,
198 name: "ActiveCalendarType",
199 kind: "CalendarTypeEnum",
200 access: Access::read_write_with(Privilege::View, Privilege::Manage),
201 qualities: AttributeQualities::NON_VOLATILE,
202 reporting: Reporting::OnChange,
203 conform: Conform {
204 clauses: &[Clause {
205 verdict: Conformance::Mandatory,
206 when: Condition::Feature(0),
207 }],
208 },
209 },
210 Attribute {
211 id: 0x0002,
212 name: "SupportedCalendarTypes",
213 kind: "list[CalendarTypeEnum]",
214 access: Access::read_only(Privilege::View),
215 qualities: AttributeQualities::FIXED,
216 reporting: Reporting::OnChange,
217 conform: Conform {
218 clauses: &[Clause {
219 verdict: Conformance::Mandatory,
220 when: Condition::Feature(0),
221 }],
222 },
223 },
224];
225
226pub const COMMANDS: &[Command] = &[];
228
229pub const EVENTS: &[Event] = &[];
231
232pub const CLUSTER: Cluster = Cluster {
234 id: ID,
235 name: "Time Format Localization",
236 revision: REVISION,
237 pics: "LTIME",
238 derived_from: None,
239 features: FEATURES,
240 attributes: ATTRIBUTES,
241 commands: COMMANDS,
242 events: EVENTS,
243};