Skip to main content

matter_kit/clusters/generated/
icd_management.rs

1// Generated by `cargo xtask` from the CSA data model 1.6. Do not edit.
2//
3// ICD Management — cluster 0x0046.
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//! ICD Management (cluster `0x0046`, revision 3).
10//!
11//! 15 identifiers, 4 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 = 0x0046;
28
29/// The highest revision the specification's history defines — what `ClusterRevision`
30/// must report (Core §7.13.1).
31pub const REVISION: u16 = 3;
32
33/// The PICS code, which a certification declaration names the cluster by.
34pub const PICS: &str = "ICDM";
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    /// Device supports attributes and commands for the Check-In Protocol support.
42    ///
43    /// Code `CIP`, bit 0.
44    pub const CHECK_IN_PROTOCOL_SUPPORT: u32 = 1 << 0;
45    /// Device supports the user active mode trigger feature.
46    ///
47    /// Code `UAT`, bit 1.
48    pub const USER_ACTIVE_MODE_TRIGGER: u32 = 1 << 1;
49    /// Device supports operating as a Long Idle Time ICD.
50    ///
51    /// Code `LITS`, bit 2.
52    pub const LONG_IDLE_TIME_SUPPORT: u32 = 1 << 2;
53    /// Device supports dynamic switching from SIT to LIT operating modes.
54    ///
55    /// Code `DSLS`, bit 3.
56    pub const DYNAMIC_SIT_LIT_SUPPORT: u32 = 1 << 3;
57}
58
59/// Every feature bit, with its conformance.
60pub const FEATURES: &[Feature] = &[
61    Feature {
62        bit: 0,
63        code: "CIP",
64        name: "CheckInProtocolSupport",
65        conform: Conform {
66            clauses: &[
67                Clause {
68                    verdict: Conformance::Mandatory,
69                    when: Condition::Feature(2),
70                },
71                Clause {
72                    verdict: Conformance::Optional,
73                    when: Condition::Always,
74                },
75            ],
76        },
77    },
78    Feature {
79        bit: 1,
80        code: "UAT",
81        name: "UserActiveModeTrigger",
82        conform: Conform {
83            clauses: &[
84                Clause {
85                    verdict: Conformance::Mandatory,
86                    when: Condition::Feature(2),
87                },
88                Clause {
89                    verdict: Conformance::Optional,
90                    when: Condition::Always,
91                },
92            ],
93        },
94    },
95    Feature {
96        bit: 2,
97        code: "LITS",
98        name: "LongIdleTimeSupport",
99        conform: Conform::OPTIONAL,
100    },
101    Feature {
102        bit: 3,
103        code: "DSLS",
104        name: "DynamicSitLitSupport",
105        conform: Conform {
106            clauses: &[Clause {
107                verdict: Conformance::Optional,
108                when: Condition::Feature(2),
109            }],
110        },
111    },
112];
113
114/// The attribute ids.
115pub mod attribute {
116    use crate::im::AttributeId;
117
118    /// `IdleModeDuration`.
119    pub const IDLE_MODE_DURATION: AttributeId = 0x00;
120    /// `ActiveModeDuration`.
121    pub const ACTIVE_MODE_DURATION: AttributeId = 0x01;
122    /// `ActiveModeThreshold`.
123    pub const ACTIVE_MODE_THRESHOLD: AttributeId = 0x02;
124    /// `RegisteredClients`.
125    pub const REGISTERED_CLIENTS: AttributeId = 0x03;
126    /// `ICDCounter`.
127    pub const ICD_COUNTER: AttributeId = 0x04;
128    /// `ClientsSupportedPerFabric`.
129    pub const CLIENTS_SUPPORTED_PER_FABRIC: AttributeId = 0x05;
130    /// `UserActiveModeTriggerHint`.
131    pub const USER_ACTIVE_MODE_TRIGGER_HINT: AttributeId = 0x06;
132    /// `UserActiveModeTriggerInstruction`.
133    pub const USER_ACTIVE_MODE_TRIGGER_INSTRUCTION: AttributeId = 0x07;
134    /// `OperatingMode`.
135    pub const OPERATING_MODE: AttributeId = 0x08;
136    /// `MaximumCheckInBackoff`.
137    pub const MAXIMUM_CHECK_IN_BACKOFF: AttributeId = 0x09;
138}
139
140/// The command ids.
141pub mod command {
142    use crate::im::CommandId;
143
144    /// `RegisterClient`.
145    pub const REGISTER_CLIENT: CommandId = 0x00;
146    /// `RegisterClientResponse`.
147    pub const REGISTER_CLIENT_RESPONSE: CommandId = 0x01;
148    /// `UnregisterClient`.
149    pub const UNREGISTER_CLIENT: CommandId = 0x02;
150    /// `StayActiveRequest`.
151    pub const STAY_ACTIVE_REQUEST: CommandId = 0x03;
152    /// `StayActiveResponse`.
153    pub const STAY_ACTIVE_RESPONSE: CommandId = 0x04;
154}
155
156/// `ClientTypeEnum`.
157#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
158#[repr(u8)]
159pub enum ClientTypeEnum {
160    /// The client is typically resident, always-on, fixed infrastructure in the home.
161    Permanent = 0,
162    /// The client is mobile or non-resident or not always-on and may not always be available in the home.
163    Ephemeral = 1,
164}
165
166impl ClientTypeEnum {
167    /// Reads a wire value, or `None` for one this revision does not define.
168    #[must_use]
169    pub const fn from_value(value: u8) -> Option<Self> {
170        match value {
171            0 => Some(Self::Permanent),
172            1 => Some(Self::Ephemeral),
173            _ => None,
174        }
175    }
176
177    /// Its wire value.
178    #[must_use]
179    pub const fn value(self) -> u8 {
180        self as u8
181    }
182}
183
184impl ToTlv for ClientTypeEnum {
185    fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
186        self.value().to_tlv(w, tag)
187    }
188}
189
190impl<'a> FromTlv<'a> for ClientTypeEnum {
191    fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
192        let value = <u8 as FromTlv<'a>>::from_tlv(reader, element)?;
193        Self::from_value(value).ok_or(crate::Error::new(crate::ErrorCode::TlvOutOfRange))
194    }
195}
196
197/// `OperatingModeEnum`.
198#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
199#[repr(u8)]
200pub enum OperatingModeEnum {
201    /// ICD is operating as a Short Idle Time ICD.
202    SIT = 0,
203    /// ICD is operating as a Long Idle Time ICD.
204    LIT = 1,
205}
206
207impl OperatingModeEnum {
208    /// Reads a wire value, or `None` for one this revision does not define.
209    #[must_use]
210    pub const fn from_value(value: u8) -> Option<Self> {
211        match value {
212            0 => Some(Self::SIT),
213            1 => Some(Self::LIT),
214            _ => None,
215        }
216    }
217
218    /// Its wire value.
219    #[must_use]
220    pub const fn value(self) -> u8 {
221        self as u8
222    }
223}
224
225impl ToTlv for OperatingModeEnum {
226    fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
227        self.value().to_tlv(w, tag)
228    }
229}
230
231impl<'a> FromTlv<'a> for OperatingModeEnum {
232    fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
233        let value = <u8 as FromTlv<'a>>::from_tlv(reader, element)?;
234        Self::from_value(value).ok_or(crate::Error::new(crate::ErrorCode::TlvOutOfRange))
235    }
236}
237
238bitflags::bitflags! {
239    /// `UserActiveModeTriggerBitmap`.
240    #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)]
241    pub struct UserActiveModeTriggerBitmap: u32 {
242        /// Power Cycle to transition the device to ActiveMode
243        const POWER_CYCLE = 1 << 0;
244        /// Settings menu on the device informs how to transition the device to ActiveMode
245        const SETTINGS_MENU = 1 << 1;
246        /// Custom Instruction on how to transition the device to ActiveMode
247        const CUSTOM_INSTRUCTION = 1 << 2;
248        /// Device Manual informs how to transition the device to ActiveMode
249        const DEVICE_MANUAL = 1 << 3;
250        /// Actuate Sensor to transition the device to ActiveMode
251        const ACTUATE_SENSOR = 1 << 4;
252        /// Actuate Sensor for N seconds to transition the device to ActiveMode
253        const ACTUATE_SENSOR_SECONDS = 1 << 5;
254        /// Actuate Sensor N times to transition the device to ActiveMode
255        const ACTUATE_SENSOR_TIMES = 1 << 6;
256        /// Actuate Sensor until light blinks to transition the device to ActiveMode
257        const ACTUATE_SENSOR_LIGHTS_BLINK = 1 << 7;
258        /// Press Reset Button to transition the device to ActiveMode
259        const RESET_BUTTON = 1 << 8;
260        /// Press Reset Button until light blinks to transition the device to ActiveMode
261        const RESET_BUTTON_LIGHTS_BLINK = 1 << 9;
262        /// Press Reset Button for N seconds to transition the device to ActiveMode
263        const RESET_BUTTON_SECONDS = 1 << 10;
264        /// Press Reset Button N times to transition the device to ActiveMode
265        const RESET_BUTTON_TIMES = 1 << 11;
266        /// Press Setup Button to transition the device to ActiveMode
267        const SETUP_BUTTON = 1 << 12;
268        /// Press Setup Button for N seconds to transition the device to ActiveMode
269        const SETUP_BUTTON_SECONDS = 1 << 13;
270        /// Press Setup Button until light blinks to transition the device to ActiveMode
271        const SETUP_BUTTON_LIGHTS_BLINK = 1 << 14;
272        /// Press Setup Button N times to transition the device to ActiveMode
273        const SETUP_BUTTON_TIMES = 1 << 15;
274        /// Press the N Button to transition the device to ActiveMode
275        const APP_DEFINED_BUTTON = 1 << 16;
276    }
277}
278
279impl ToTlv for UserActiveModeTriggerBitmap {
280    fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
281        self.bits().to_tlv(w, tag)
282    }
283}
284
285impl<'a> FromTlv<'a> for UserActiveModeTriggerBitmap {
286    fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
287        let bits = <u32 as FromTlv<'a>>::from_tlv(reader, element)?;
288        Self::from_bits(bits).ok_or(crate::Error::new(crate::ErrorCode::TlvOutOfRange))
289    }
290}
291
292/// `MonitoringRegistrationStruct`, fabric-scoped — §7.19.1.9's `FabricIndex` is field 254.
293#[derive(Debug, Clone, Copy, PartialEq)]
294pub struct MonitoringRegistrationStruct {
295    /// `CheckInNodeID`, field 1.
296    pub check_in_node_id: crate::msg::NodeId,
297    /// `MonitoredSubject`, field 2.
298    pub monitored_subject: u64,
299    /// `ClientType`, field 4.
300    pub client_type: ClientTypeEnum,
301    /// `FabricIndex`, field 254.
302    pub fabric_index: crate::msg::FabricIndex,
303}
304
305impl ToTlv for MonitoringRegistrationStruct {
306    fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
307        w.start_structure(tag)?;
308        self.check_in_node_id.to_tlv(w, Tag::Context(1))?;
309        self.monitored_subject.to_tlv(w, Tag::Context(2))?;
310        self.client_type.to_tlv(w, Tag::Context(4))?;
311        self.fabric_index.to_tlv(w, Tag::Context(254))?;
312        w.end_container()
313    }
314}
315
316impl<'a> FromTlv<'a> for MonitoringRegistrationStruct {
317    fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
318        if element.value.container() != Some(ContainerKind::Structure) {
319            return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
320        }
321        let mut check_in_node_id = None;
322        let mut monitored_subject = None;
323        let mut client_type = None;
324        let mut fabric_index = None;
325        loop {
326            let Some(field) = reader.next_element()? else {
327                return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
328            };
329            if field.value == Value::EndOfContainer {
330                break;
331            }
332            match field.tag.context() {
333                Some(1) => check_in_node_id = Some(<crate::msg::NodeId>::from_tlv(reader, &field)?),
334                Some(2) => monitored_subject = Some(<u64>::from_tlv(reader, &field)?),
335                Some(4) => client_type = Some(<ClientTypeEnum>::from_tlv(reader, &field)?),
336                Some(254) => {
337                    fabric_index = Some(<crate::msg::FabricIndex>::from_tlv(reader, &field)?)
338                }
339                // A field this revision does not define. §7.19.2: a receiver
340                // ignores what it does not know rather than refusing the whole
341                // structure, which is what lets a newer peer talk to an older one.
342                _ => reader.skip_value(&field)?,
343            }
344        }
345        Ok(Self {
346            check_in_node_id: check_in_node_id
347                .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
348            monitored_subject: monitored_subject
349                .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
350            client_type: client_type.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
351            fabric_index: fabric_index.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
352        })
353    }
354}
355
356/// The fields of `RegisterClient` (command `0x00`).
357#[derive(Debug, Clone, Copy, PartialEq)]
358pub struct RegisterClientFields<'a> {
359    /// `CheckInNodeID`, field 0.
360    pub check_in_node_id: crate::msg::NodeId,
361    /// `MonitoredSubject`, field 1.
362    pub monitored_subject: u64,
363    /// `Key`, field 2.
364    pub key: &'a [u8],
365    /// `VerificationKey`, field 3.
366    pub verification_key: Option<&'a [u8]>,
367    /// `ClientType`, field 4.
368    pub client_type: ClientTypeEnum,
369}
370
371impl<'a> ToTlv for RegisterClientFields<'a> {
372    fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
373        w.start_structure(tag)?;
374        self.check_in_node_id.to_tlv(w, Tag::Context(0))?;
375        self.monitored_subject.to_tlv(w, Tag::Context(1))?;
376        self.key.to_tlv(w, Tag::Context(2))?;
377        if let Some(value) = &self.verification_key {
378            value.to_tlv(w, Tag::Context(3))?;
379        }
380        self.client_type.to_tlv(w, Tag::Context(4))?;
381        w.end_container()
382    }
383}
384
385impl<'a> FromTlv<'a> for RegisterClientFields<'a> {
386    fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
387        if element.value.container() != Some(ContainerKind::Structure) {
388            return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
389        }
390        let mut check_in_node_id = None;
391        let mut monitored_subject = None;
392        let mut key = None;
393        let mut verification_key = None;
394        let mut client_type = None;
395        loop {
396            let Some(field) = reader.next_element()? else {
397                return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
398            };
399            if field.value == Value::EndOfContainer {
400                break;
401            }
402            match field.tag.context() {
403                Some(0) => check_in_node_id = Some(<crate::msg::NodeId>::from_tlv(reader, &field)?),
404                Some(1) => monitored_subject = Some(<u64>::from_tlv(reader, &field)?),
405                Some(2) => key = Some(<&'a [u8]>::from_tlv(reader, &field)?),
406                Some(3) => verification_key = Some(<&'a [u8]>::from_tlv(reader, &field)?),
407                Some(4) => client_type = Some(<ClientTypeEnum>::from_tlv(reader, &field)?),
408                // A field this revision does not define. §7.19.2: a receiver
409                // ignores what it does not know rather than refusing the whole
410                // structure, which is what lets a newer peer talk to an older one.
411                _ => reader.skip_value(&field)?,
412            }
413        }
414        Ok(Self {
415            check_in_node_id: check_in_node_id
416                .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
417            monitored_subject: monitored_subject
418                .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
419            key: key.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
420            verification_key,
421            client_type: client_type.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
422        })
423    }
424}
425
426/// The fields of `RegisterClientResponse` (command `0x01`).
427#[derive(Debug, Clone, Copy, PartialEq)]
428pub struct RegisterClientResponseFields {
429    /// `ICDCounter`, field 0.
430    pub icd_counter: u32,
431}
432
433impl ToTlv for RegisterClientResponseFields {
434    fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
435        w.start_structure(tag)?;
436        self.icd_counter.to_tlv(w, Tag::Context(0))?;
437        w.end_container()
438    }
439}
440
441impl<'a> FromTlv<'a> for RegisterClientResponseFields {
442    fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
443        if element.value.container() != Some(ContainerKind::Structure) {
444            return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
445        }
446        let mut icd_counter = None;
447        loop {
448            let Some(field) = reader.next_element()? else {
449                return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
450            };
451            if field.value == Value::EndOfContainer {
452                break;
453            }
454            match field.tag.context() {
455                Some(0) => icd_counter = Some(<u32>::from_tlv(reader, &field)?),
456                // A field this revision does not define. §7.19.2: a receiver
457                // ignores what it does not know rather than refusing the whole
458                // structure, which is what lets a newer peer talk to an older one.
459                _ => reader.skip_value(&field)?,
460            }
461        }
462        Ok(Self {
463            icd_counter: icd_counter.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
464        })
465    }
466}
467
468/// The fields of `UnregisterClient` (command `0x02`).
469#[derive(Debug, Clone, Copy, PartialEq)]
470pub struct UnregisterClientFields<'a> {
471    /// `CheckInNodeID`, field 0.
472    pub check_in_node_id: crate::msg::NodeId,
473    /// `VerificationKey`, field 1.
474    pub verification_key: Option<&'a [u8]>,
475}
476
477impl<'a> ToTlv for UnregisterClientFields<'a> {
478    fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
479        w.start_structure(tag)?;
480        self.check_in_node_id.to_tlv(w, Tag::Context(0))?;
481        if let Some(value) = &self.verification_key {
482            value.to_tlv(w, Tag::Context(1))?;
483        }
484        w.end_container()
485    }
486}
487
488impl<'a> FromTlv<'a> for UnregisterClientFields<'a> {
489    fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
490        if element.value.container() != Some(ContainerKind::Structure) {
491            return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
492        }
493        let mut check_in_node_id = None;
494        let mut verification_key = None;
495        loop {
496            let Some(field) = reader.next_element()? else {
497                return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
498            };
499            if field.value == Value::EndOfContainer {
500                break;
501            }
502            match field.tag.context() {
503                Some(0) => check_in_node_id = Some(<crate::msg::NodeId>::from_tlv(reader, &field)?),
504                Some(1) => verification_key = Some(<&'a [u8]>::from_tlv(reader, &field)?),
505                // A field this revision does not define. §7.19.2: a receiver
506                // ignores what it does not know rather than refusing the whole
507                // structure, which is what lets a newer peer talk to an older one.
508                _ => reader.skip_value(&field)?,
509            }
510        }
511        Ok(Self {
512            check_in_node_id: check_in_node_id
513                .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
514            verification_key,
515        })
516    }
517}
518
519/// The fields of `StayActiveRequest` (command `0x03`).
520#[derive(Debug, Clone, Copy, PartialEq)]
521pub struct StayActiveRequestFields {
522    /// `StayActiveDuration`, field 0.
523    pub stay_active_duration: u32,
524}
525
526impl ToTlv for StayActiveRequestFields {
527    fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
528        w.start_structure(tag)?;
529        self.stay_active_duration.to_tlv(w, Tag::Context(0))?;
530        w.end_container()
531    }
532}
533
534impl<'a> FromTlv<'a> for StayActiveRequestFields {
535    fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
536        if element.value.container() != Some(ContainerKind::Structure) {
537            return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
538        }
539        let mut stay_active_duration = None;
540        loop {
541            let Some(field) = reader.next_element()? else {
542                return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
543            };
544            if field.value == Value::EndOfContainer {
545                break;
546            }
547            match field.tag.context() {
548                Some(0) => stay_active_duration = Some(<u32>::from_tlv(reader, &field)?),
549                // A field this revision does not define. §7.19.2: a receiver
550                // ignores what it does not know rather than refusing the whole
551                // structure, which is what lets a newer peer talk to an older one.
552                _ => reader.skip_value(&field)?,
553            }
554        }
555        Ok(Self {
556            stay_active_duration: stay_active_duration
557                .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
558        })
559    }
560}
561
562/// The fields of `StayActiveResponse` (command `0x04`).
563#[derive(Debug, Clone, Copy, PartialEq)]
564pub struct StayActiveResponseFields {
565    /// `PromisedActiveDuration`, field 0.
566    pub promised_active_duration: u32,
567}
568
569impl ToTlv for StayActiveResponseFields {
570    fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
571        w.start_structure(tag)?;
572        self.promised_active_duration.to_tlv(w, Tag::Context(0))?;
573        w.end_container()
574    }
575}
576
577impl<'a> FromTlv<'a> for StayActiveResponseFields {
578    fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
579        if element.value.container() != Some(ContainerKind::Structure) {
580            return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
581        }
582        let mut promised_active_duration = None;
583        loop {
584            let Some(field) = reader.next_element()? else {
585                return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
586            };
587            if field.value == Value::EndOfContainer {
588                break;
589            }
590            match field.tag.context() {
591                Some(0) => promised_active_duration = Some(<u32>::from_tlv(reader, &field)?),
592                // A field this revision does not define. §7.19.2: a receiver
593                // ignores what it does not know rather than refusing the whole
594                // structure, which is what lets a newer peer talk to an older one.
595                _ => reader.skip_value(&field)?,
596            }
597        }
598        Ok(Self {
599            promised_active_duration: promised_active_duration
600                .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
601        })
602    }
603}
604
605/// Every attribute the specification defines, with its conformance.
606pub const ATTRIBUTES: &[Attribute] = &[
607    Attribute {
608        id: 0x0000,
609        name: "IdleModeDuration",
610        kind: "uint32",
611        access: Access::read_only(Privilege::View),
612        qualities: AttributeQualities::FIXED,
613        reporting: Reporting::OnChange,
614        conform: Conform::MANDATORY,
615    },
616    Attribute {
617        id: 0x0001,
618        name: "ActiveModeDuration",
619        kind: "uint32",
620        access: Access::read_only(Privilege::View),
621        qualities: AttributeQualities::FIXED,
622        reporting: Reporting::OnChange,
623        conform: Conform::MANDATORY,
624    },
625    Attribute {
626        id: 0x0002,
627        name: "ActiveModeThreshold",
628        kind: "uint16",
629        access: Access::read_only(Privilege::View),
630        qualities: AttributeQualities::FIXED,
631        reporting: Reporting::OnChange,
632        conform: Conform::MANDATORY,
633    },
634    Attribute {
635        id: 0x0003,
636        name: "RegisteredClients",
637        kind: "list[MonitoringRegistrationStruct]",
638        access: Access::read_only(Privilege::Administer)
639            .with_qualities(AccessQualities::FABRIC_SCOPED),
640        qualities: AttributeQualities::NON_VOLATILE,
641        reporting: Reporting::OnChange,
642        conform: Conform {
643            clauses: &[Clause {
644                verdict: Conformance::Mandatory,
645                when: Condition::Feature(0),
646            }],
647        },
648    },
649    Attribute {
650        id: 0x0004,
651        name: "ICDCounter",
652        kind: "uint32",
653        access: Access::read_only(Privilege::Administer),
654        qualities: AttributeQualities::NON_VOLATILE,
655        reporting: Reporting::ChangesOmitted,
656        conform: Conform {
657            clauses: &[Clause {
658                verdict: Conformance::Mandatory,
659                when: Condition::Feature(0),
660            }],
661        },
662    },
663    Attribute {
664        id: 0x0005,
665        name: "ClientsSupportedPerFabric",
666        kind: "uint16",
667        access: Access::read_only(Privilege::View),
668        qualities: AttributeQualities::FIXED,
669        reporting: Reporting::OnChange,
670        conform: Conform {
671            clauses: &[Clause {
672                verdict: Conformance::Mandatory,
673                when: Condition::Feature(0),
674            }],
675        },
676    },
677    Attribute {
678        id: 0x0006,
679        name: "UserActiveModeTriggerHint",
680        kind: "UserActiveModeTriggerBitmap",
681        access: Access::read_only(Privilege::View),
682        qualities: AttributeQualities::FIXED,
683        reporting: Reporting::OnChange,
684        conform: Conform {
685            clauses: &[Clause {
686                verdict: Conformance::Mandatory,
687                when: Condition::Feature(1),
688            }],
689        },
690    },
691    Attribute {
692        id: 0x0007,
693        name: "UserActiveModeTriggerInstruction",
694        kind: "string",
695        access: Access::read_only(Privilege::View),
696        qualities: AttributeQualities::FIXED,
697        reporting: Reporting::OnChange,
698        conform: Conform::DESCRIBED,
699    },
700    Attribute {
701        id: 0x0008,
702        name: "OperatingMode",
703        kind: "OperatingModeEnum",
704        access: Access::read_only(Privilege::View),
705        qualities: AttributeQualities::empty(),
706        reporting: Reporting::OnChange,
707        conform: Conform {
708            clauses: &[Clause {
709                verdict: Conformance::Mandatory,
710                when: Condition::Feature(2),
711            }],
712        },
713    },
714    Attribute {
715        id: 0x0009,
716        name: "MaximumCheckInBackoff",
717        kind: "uint32",
718        access: Access::read_only(Privilege::View),
719        qualities: AttributeQualities::FIXED,
720        reporting: Reporting::OnChange,
721        conform: Conform {
722            clauses: &[Clause {
723                verdict: Conformance::Mandatory,
724                when: Condition::Feature(0),
725            }],
726        },
727    },
728];
729
730/// Every command, with its conformance.
731pub const COMMANDS: &[Command] = &[
732    Command {
733        id: 0x00,
734        name: "RegisterClient",
735        to_server: true,
736        response: Some(0x01),
737        access: Access::invoke(Privilege::Manage).with_qualities(AccessQualities::FABRIC_SCOPED),
738        conform: Conform {
739            clauses: &[Clause {
740                verdict: Conformance::Mandatory,
741                when: Condition::Feature(0),
742            }],
743        },
744    },
745    Command {
746        id: 0x01,
747        name: "RegisterClientResponse",
748        to_server: false,
749        response: None,
750        access: Access::invoke(Privilege::Operate),
751        conform: Conform {
752            clauses: &[Clause {
753                verdict: Conformance::Mandatory,
754                when: Condition::Feature(0),
755            }],
756        },
757    },
758    Command {
759        id: 0x02,
760        name: "UnregisterClient",
761        to_server: true,
762        response: None,
763        access: Access::invoke(Privilege::Manage).with_qualities(AccessQualities::FABRIC_SCOPED),
764        conform: Conform {
765            clauses: &[Clause {
766                verdict: Conformance::Mandatory,
767                when: Condition::Feature(0),
768            }],
769        },
770    },
771    Command {
772        id: 0x03,
773        name: "StayActiveRequest",
774        to_server: true,
775        response: Some(0x04),
776        access: Access::invoke(Privilege::Operate),
777        conform: Conform {
778            clauses: &[
779                Clause {
780                    verdict: Conformance::Mandatory,
781                    when: Condition::Feature(2),
782                },
783                Clause {
784                    verdict: Conformance::Optional,
785                    when: Condition::Always,
786                },
787            ],
788        },
789    },
790    Command {
791        id: 0x04,
792        name: "StayActiveResponse",
793        to_server: false,
794        response: None,
795        access: Access::invoke(Privilege::Operate),
796        conform: Conform {
797            clauses: &[
798                Clause {
799                    verdict: Conformance::Mandatory,
800                    when: Condition::Feature(2),
801                },
802                Clause {
803                    verdict: Conformance::Optional,
804                    when: Condition::Always,
805                },
806            ],
807        },
808    },
809];
810
811/// Every event, with its conformance.
812pub const EVENTS: &[Event] = &[];
813
814/// The whole cluster, as the specification defines it.
815pub const CLUSTER: Cluster = Cluster {
816    id: ID,
817    name: "ICD Management",
818    revision: REVISION,
819    pics: "ICDM",
820    derived_from: None,
821    features: FEATURES,
822    attributes: ATTRIBUTES,
823    commands: COMMANDS,
824    events: EVENTS,
825};