Skip to main content

matter_kit/clusters/generated/
time_format_localization.rs

1// Generated by `cargo xtask` from the CSA data model 1.6. Do not edit.
2//
3// Time Format Localization — cluster 0x002C.
4//
5// Regenerate with `cargo xtask clusters --dm <checkout>/data_model/1.6`; `cargo xtask check`
6// is the CI gate that keeps this file honest. The XML itself is not vendored here — it
7// carries the CSA's own copyright notice and is not redistributable.
8
9//! Time Format Localization (cluster `0x002C`, revision 1).
10//!
11//! 3 identifiers, 1 feature bits, and the specification's own conformance for
12//! every element. `CLUSTER` is the whole table.
13
14#![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
26/// The cluster id.
27pub const ID: ClusterId = 0x002C;
28
29/// The highest revision the specification's history defines — what `ClusterRevision`
30/// must report (Core §7.13.1).
31pub const REVISION: u16 = 1;
32
33/// The PICS code, which a certification declaration names the cluster by.
34pub const PICS: &str = "LTIME";
35
36/// The `FeatureMap` bits (Core §7.13.2).
37///
38/// A feature has conformance of its own: a device may not claim one the
39/// specification forbids it alongside another.
40pub mod feature {
41    /// The Node can be configured to use different calendar formats when conveying values to a user.
42    ///
43    /// Code `CALFMT`, bit 0.
44    pub const CALENDAR_FORMAT: u32 = 1 << 0;
45}
46
47/// Every feature bit, with its conformance.
48pub const FEATURES: &[Feature] = &[Feature {
49    bit: 0,
50    code: "CALFMT",
51    name: "CalendarFormat",
52    conform: Conform::OPTIONAL,
53}];
54
55/// The attribute ids.
56pub mod attribute {
57    use crate::im::AttributeId;
58
59    /// `HourFormat`.
60    pub const HOUR_FORMAT: AttributeId = 0x00;
61    /// `ActiveCalendarType`.
62    pub const ACTIVE_CALENDAR_TYPE: AttributeId = 0x01;
63    /// `SupportedCalendarTypes`.
64    pub const SUPPORTED_CALENDAR_TYPES: AttributeId = 0x02;
65}
66
67/// `CalendarTypeEnum`.
68#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
69#[repr(u8)]
70pub enum CalendarTypeEnum {
71    /// Dates conveyed using the Buddhist calendar
72    Buddhist = 0,
73    /// Dates conveyed using the Chinese calendar
74    Chinese = 1,
75    /// Dates conveyed using the Coptic calendar
76    Coptic = 2,
77    /// Dates conveyed using the Ethiopian calendar
78    Ethiopian = 3,
79    /// Dates conveyed using the Gregorian calendar
80    Gregorian = 4,
81    /// Dates conveyed using the Hebrew calendar
82    Hebrew = 5,
83    /// Dates conveyed using the Indian calendar
84    Indian = 6,
85    /// Dates conveyed using the Islamic calendar
86    Islamic = 7,
87    /// Dates conveyed using the Japanese calendar
88    Japanese = 8,
89    /// Dates conveyed using the Korean calendar
90    Korean = 9,
91    /// Dates conveyed using the Persian calendar
92    Persian = 10,
93    /// Dates conveyed using the Taiwanese calendar
94    Taiwanese = 11,
95    /// calendar implied from active locale
96    UseActiveLocale = 255,
97}
98
99impl CalendarTypeEnum {
100    /// Reads a wire value, or `None` for one this revision does not define.
101    #[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    /// Its wire value.
122    #[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/// `HourFormatEnum`.
142#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
143#[repr(u8)]
144pub enum HourFormatEnum {
145    /// Time conveyed with a 12-hour clock
146    N12Hr = 0,
147    /// Time conveyed with a 24-hour clock
148    N24Hr = 1,
149    /// Use active locale clock
150    UseActiveLocale = 255,
151}
152
153impl HourFormatEnum {
154    /// Reads a wire value, or `None` for one this revision does not define.
155    #[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    /// Its wire value.
166    #[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
185/// Every attribute the specification defines, with its conformance.
186pub 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
226/// Every command, with its conformance.
227pub const COMMANDS: &[Command] = &[];
228
229/// Every event, with its conformance.
230pub const EVENTS: &[Event] = &[];
231
232/// The whole cluster, as the specification defines it.
233pub 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};