Skip to main content

matter_kit/clusters/generated/
content_control.rs

1// Generated by `cargo xtask` from the CSA data model 1.6. Do not edit.
2//
3// Content Control — cluster 0x050F.
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//! Content Control (cluster `0x050F`, revision 1).
10//!
11//! 30 identifiers, 8 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 = 0x050F;
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 = "CONCON";
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    /// Supports managing screen time limits.
42    ///
43    /// Code `ST`, bit 0.
44    pub const SCREEN_TIME: u32 = 1 << 0;
45    /// Supports managing a PIN code which is used for restricting access to configuration of this feature.
46    ///
47    /// Code `PM`, bit 1.
48    pub const PIN_MANAGEMENT: u32 = 1 << 1;
49    /// Supports managing content controls for unrated content.
50    ///
51    /// Code `BU`, bit 2.
52    pub const BLOCK_UNRATED: u32 = 1 << 2;
53    /// Supports managing content controls based upon rating threshold for on demand content.
54    ///
55    /// Code `OCR`, bit 3.
56    pub const ON_DEMAND_CONTENT_RATING: u32 = 1 << 3;
57    /// Supports managing content controls based upon rating threshold for scheduled content.
58    ///
59    /// Code `SCR`, bit 4.
60    pub const SCHEDULED_CONTENT_RATING: u32 = 1 << 4;
61    /// Supports managing a set of channels that are prohibited.
62    ///
63    /// Code `BC`, bit 5.
64    pub const BLOCK_CHANNELS: u32 = 1 << 5;
65    /// Supports managing a set of applications that are prohibited.
66    ///
67    /// Code `BA`, bit 6.
68    pub const BLOCK_APPLICATIONS: u32 = 1 << 6;
69    /// Supports managing content controls based upon setting time window in which all contents and applications SHALL be blocked.
70    ///
71    /// Code `BTW`, bit 7.
72    pub const BLOCK_CONTENT_TIME_WINDOW: u32 = 1 << 7;
73}
74
75/// Every feature bit, with its conformance.
76pub const FEATURES: &[Feature] = &[
77    Feature {
78        bit: 0,
79        code: "ST",
80        name: "ScreenTime",
81        conform: Conform::OPTIONAL,
82    },
83    Feature {
84        bit: 1,
85        code: "PM",
86        name: "PINManagement",
87        conform: Conform::OPTIONAL,
88    },
89    Feature {
90        bit: 2,
91        code: "BU",
92        name: "BlockUnrated",
93        conform: Conform::OPTIONAL,
94    },
95    Feature {
96        bit: 3,
97        code: "OCR",
98        name: "OnDemandContentRating",
99        conform: Conform::OPTIONAL,
100    },
101    Feature {
102        bit: 4,
103        code: "SCR",
104        name: "ScheduledContentRating",
105        conform: Conform::OPTIONAL,
106    },
107    Feature {
108        bit: 5,
109        code: "BC",
110        name: "BlockChannels",
111        conform: Conform::OPTIONAL,
112    },
113    Feature {
114        bit: 6,
115        code: "BA",
116        name: "BlockApplications",
117        conform: Conform::OPTIONAL,
118    },
119    Feature {
120        bit: 7,
121        code: "BTW",
122        name: "BlockContentTimeWindow",
123        conform: Conform::OPTIONAL,
124    },
125];
126
127/// The attribute ids.
128pub mod attribute {
129    use crate::im::AttributeId;
130
131    /// `Enabled`.
132    pub const ENABLED: AttributeId = 0x00;
133    /// `OnDemandRatings`.
134    pub const ON_DEMAND_RATINGS: AttributeId = 0x01;
135    /// `OnDemandRatingThreshold`.
136    pub const ON_DEMAND_RATING_THRESHOLD: AttributeId = 0x02;
137    /// `ScheduledContentRatings`.
138    pub const SCHEDULED_CONTENT_RATINGS: AttributeId = 0x03;
139    /// `ScheduledContentRatingThreshold`.
140    pub const SCHEDULED_CONTENT_RATING_THRESHOLD: AttributeId = 0x04;
141    /// `ScreenDailyTime`.
142    pub const SCREEN_DAILY_TIME: AttributeId = 0x05;
143    /// `RemainingScreenTime`.
144    pub const REMAINING_SCREEN_TIME: AttributeId = 0x06;
145    /// `BlockUnrated`.
146    pub const BLOCK_UNRATED: AttributeId = 0x07;
147    /// `BlockChannelList`.
148    pub const BLOCK_CHANNEL_LIST: AttributeId = 0x08;
149    /// `BlockApplicationList`.
150    pub const BLOCK_APPLICATION_LIST: AttributeId = 0x09;
151    /// `BlockContentTimeWindow`.
152    pub const BLOCK_CONTENT_TIME_WINDOW: AttributeId = 0x0A;
153}
154
155/// The command ids.
156pub mod command {
157    use crate::im::CommandId;
158
159    /// `UpdatePIN`.
160    pub const UPDATE_PIN: CommandId = 0x00;
161    /// `ResetPIN`.
162    pub const RESET_PIN: CommandId = 0x01;
163    /// `ResetPINResponse`.
164    pub const RESET_PIN_RESPONSE: CommandId = 0x02;
165    /// `Enable`.
166    pub const ENABLE: CommandId = 0x03;
167    /// `Disable`.
168    pub const DISABLE: CommandId = 0x04;
169    /// `AddBonusTime`.
170    pub const ADD_BONUS_TIME: CommandId = 0x05;
171    /// `SetScreenDailyTime`.
172    pub const SET_SCREEN_DAILY_TIME: CommandId = 0x06;
173    /// `BlockUnratedContent`.
174    pub const BLOCK_UNRATED_CONTENT: CommandId = 0x07;
175    /// `UnblockUnratedContent`.
176    pub const UNBLOCK_UNRATED_CONTENT: CommandId = 0x08;
177    /// `SetOnDemandRatingThreshold`.
178    pub const SET_ON_DEMAND_RATING_THRESHOLD: CommandId = 0x09;
179    /// `SetScheduledContentRatingThreshold`.
180    pub const SET_SCHEDULED_CONTENT_RATING_THRESHOLD: CommandId = 0x0A;
181    /// `AddBlockChannels`.
182    pub const ADD_BLOCK_CHANNELS: CommandId = 0x0B;
183    /// `RemoveBlockChannels`.
184    pub const REMOVE_BLOCK_CHANNELS: CommandId = 0x0C;
185    /// `AddBlockApplications`.
186    pub const ADD_BLOCK_APPLICATIONS: CommandId = 0x0D;
187    /// `RemoveBlockApplications`.
188    pub const REMOVE_BLOCK_APPLICATIONS: CommandId = 0x0E;
189    /// `SetBlockContentTimeWindow`.
190    pub const SET_BLOCK_CONTENT_TIME_WINDOW: CommandId = 0x0F;
191    /// `RemoveBlockContentTimeWindow`.
192    pub const REMOVE_BLOCK_CONTENT_TIME_WINDOW: CommandId = 0x10;
193}
194
195/// The event ids.
196pub mod event {
197    use crate::im::EventId;
198
199    /// `RemainingScreenTimeExpired`.
200    pub const REMAINING_SCREEN_TIME_EXPIRED: EventId = 0x00;
201    /// `EnteringBlockContentTimeWindow`.
202    pub const ENTERING_BLOCK_CONTENT_TIME_WINDOW: EventId = 0x01;
203}
204
205/// `StatusCodeEnum`.
206#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
207#[repr(u8)]
208pub enum StatusCodeEnum {
209    /// Provided PIN Code does not match the current PIN code.
210    InvalidPINCode = 2,
211    /// Provided Rating is out of scope of the corresponding Rating list.
212    InvalidRating = 3,
213    /// Provided Channel(s) is invalid.
214    InvalidChannel = 4,
215    /// Provided Channel(s) already exists.
216    ChannelAlreadyExist = 5,
217    /// Provided Channel(s) doesn't exist in BlockChannelList attribute.
218    ChannelNotExist = 6,
219    /// Provided Application(s) is not identified.
220    UnidentifiableApplication = 7,
221    /// Provided Application(s) already exists.
222    ApplicationAlreadyExist = 8,
223    /// Provided Application(s) doesn't exist in BlockApplicationList attribute.
224    ApplicationNotExist = 9,
225    /// Provided time Window already exists in BlockContentTimeWindow attribute.
226    TimeWindowAlreadyExist = 10,
227    /// Provided time window doesn't exist in BlockContentTimeWindow attribute.
228    TimeWindowNotExist = 11,
229}
230
231impl StatusCodeEnum {
232    /// Reads a wire value, or `None` for one this revision does not define.
233    #[must_use]
234    pub const fn from_value(value: u8) -> Option<Self> {
235        match value {
236            2 => Some(Self::InvalidPINCode),
237            3 => Some(Self::InvalidRating),
238            4 => Some(Self::InvalidChannel),
239            5 => Some(Self::ChannelAlreadyExist),
240            6 => Some(Self::ChannelNotExist),
241            7 => Some(Self::UnidentifiableApplication),
242            8 => Some(Self::ApplicationAlreadyExist),
243            9 => Some(Self::ApplicationNotExist),
244            10 => Some(Self::TimeWindowAlreadyExist),
245            11 => Some(Self::TimeWindowNotExist),
246            _ => None,
247        }
248    }
249
250    /// Its wire value.
251    #[must_use]
252    pub const fn value(self) -> u8 {
253        self as u8
254    }
255}
256
257impl ToTlv for StatusCodeEnum {
258    fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
259        self.value().to_tlv(w, tag)
260    }
261}
262
263impl<'a> FromTlv<'a> for StatusCodeEnum {
264    fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
265        let value = <u8 as FromTlv<'a>>::from_tlv(reader, element)?;
266        Self::from_value(value).ok_or(crate::Error::new(crate::ErrorCode::TlvOutOfRange))
267    }
268}
269
270bitflags::bitflags! {
271    /// `DayOfWeekBitmap`.
272    #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default)]
273    pub struct DayOfWeekBitmap: u8 {
274        /// Sunday
275        const SUNDAY = 1 << 0;
276        /// Monday
277        const MONDAY = 1 << 1;
278        /// Tuesday
279        const TUESDAY = 1 << 2;
280        /// Wednesday
281        const WEDNESDAY = 1 << 3;
282        /// Thursday
283        const THURSDAY = 1 << 4;
284        /// Friday
285        const FRIDAY = 1 << 5;
286        /// Saturday
287        const SATURDAY = 1 << 6;
288    }
289}
290
291impl ToTlv for DayOfWeekBitmap {
292    fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
293        self.bits().to_tlv(w, tag)
294    }
295}
296
297impl<'a> FromTlv<'a> for DayOfWeekBitmap {
298    fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
299        let bits = <u8 as FromTlv<'a>>::from_tlv(reader, element)?;
300        Self::from_bits(bits).ok_or(crate::Error::new(crate::ErrorCode::TlvOutOfRange))
301    }
302}
303
304/// `AppInfoStruct`.
305#[derive(Debug, Clone, Copy, PartialEq)]
306pub struct AppInfoStruct<'a> {
307    /// `CatalogVendorID`, field 0.
308    pub catalog_vendor_id: u16,
309    /// `ApplicationID`, field 1.
310    pub application_id: &'a str,
311}
312
313impl<'a> ToTlv for AppInfoStruct<'a> {
314    fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
315        w.start_structure(tag)?;
316        self.catalog_vendor_id.to_tlv(w, Tag::Context(0))?;
317        self.application_id.to_tlv(w, Tag::Context(1))?;
318        w.end_container()
319    }
320}
321
322impl<'a> FromTlv<'a> for AppInfoStruct<'a> {
323    fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
324        if element.value.container() != Some(ContainerKind::Structure) {
325            return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
326        }
327        let mut catalog_vendor_id = None;
328        let mut application_id = None;
329        loop {
330            let Some(field) = reader.next_element()? else {
331                return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
332            };
333            if field.value == Value::EndOfContainer {
334                break;
335            }
336            match field.tag.context() {
337                Some(0) => catalog_vendor_id = Some(<u16>::from_tlv(reader, &field)?),
338                Some(1) => application_id = Some(<&'a str>::from_tlv(reader, &field)?),
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            catalog_vendor_id: catalog_vendor_id
347                .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
348            application_id: application_id
349                .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
350        })
351    }
352}
353
354/// `BlockChannelStruct`.
355#[derive(Debug, Clone, Copy, PartialEq)]
356pub struct BlockChannelStruct<'a> {
357    /// `BlockChannelIndex`, field 0.
358    pub block_channel_index: Nullable<u16>,
359    /// `MajorNumber`, field 1.
360    pub major_number: u16,
361    /// `MinorNumber`, field 2.
362    pub minor_number: u16,
363    /// `Identifier`, field 3.
364    pub identifier: Option<&'a str>,
365}
366
367impl<'a> ToTlv for BlockChannelStruct<'a> {
368    fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
369        w.start_structure(tag)?;
370        self.block_channel_index.to_tlv(w, Tag::Context(0))?;
371        self.major_number.to_tlv(w, Tag::Context(1))?;
372        self.minor_number.to_tlv(w, Tag::Context(2))?;
373        if let Some(value) = &self.identifier {
374            value.to_tlv(w, Tag::Context(3))?;
375        }
376        w.end_container()
377    }
378}
379
380impl<'a> FromTlv<'a> for BlockChannelStruct<'a> {
381    fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
382        if element.value.container() != Some(ContainerKind::Structure) {
383            return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
384        }
385        let mut block_channel_index = None;
386        let mut major_number = None;
387        let mut minor_number = None;
388        let mut identifier = None;
389        loop {
390            let Some(field) = reader.next_element()? else {
391                return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
392            };
393            if field.value == Value::EndOfContainer {
394                break;
395            }
396            match field.tag.context() {
397                Some(0) => block_channel_index = Some(<Nullable<u16>>::from_tlv(reader, &field)?),
398                Some(1) => major_number = Some(<u16>::from_tlv(reader, &field)?),
399                Some(2) => minor_number = Some(<u16>::from_tlv(reader, &field)?),
400                Some(3) => identifier = Some(<&'a str>::from_tlv(reader, &field)?),
401                // A field this revision does not define. §7.19.2: a receiver
402                // ignores what it does not know rather than refusing the whole
403                // structure, which is what lets a newer peer talk to an older one.
404                _ => reader.skip_value(&field)?,
405            }
406        }
407        Ok(Self {
408            block_channel_index: block_channel_index
409                .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
410            major_number: major_number.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
411            minor_number: minor_number.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
412            identifier,
413        })
414    }
415}
416
417/// `RatingNameStruct`.
418#[derive(Debug, Clone, Copy, PartialEq)]
419pub struct RatingNameStruct<'a> {
420    /// `RatingName`, field 0.
421    pub rating_name: &'a str,
422    /// `RatingNameDesc`, field 1.
423    pub rating_name_desc: Option<&'a str>,
424}
425
426impl<'a> ToTlv for RatingNameStruct<'a> {
427    fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
428        w.start_structure(tag)?;
429        self.rating_name.to_tlv(w, Tag::Context(0))?;
430        if let Some(value) = &self.rating_name_desc {
431            value.to_tlv(w, Tag::Context(1))?;
432        }
433        w.end_container()
434    }
435}
436
437impl<'a> FromTlv<'a> for RatingNameStruct<'a> {
438    fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
439        if element.value.container() != Some(ContainerKind::Structure) {
440            return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
441        }
442        let mut rating_name = None;
443        let mut rating_name_desc = None;
444        loop {
445            let Some(field) = reader.next_element()? else {
446                return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
447            };
448            if field.value == Value::EndOfContainer {
449                break;
450            }
451            match field.tag.context() {
452                Some(0) => rating_name = Some(<&'a str>::from_tlv(reader, &field)?),
453                Some(1) => rating_name_desc = Some(<&'a str>::from_tlv(reader, &field)?),
454                // A field this revision does not define. §7.19.2: a receiver
455                // ignores what it does not know rather than refusing the whole
456                // structure, which is what lets a newer peer talk to an older one.
457                _ => reader.skip_value(&field)?,
458            }
459        }
460        Ok(Self {
461            rating_name: rating_name.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
462            rating_name_desc,
463        })
464    }
465}
466
467/// `TimePeriodStruct`.
468#[derive(Debug, Clone, Copy, PartialEq)]
469pub struct TimePeriodStruct {
470    /// `StartHour`, field 0.
471    pub start_hour: u8,
472    /// `StartMinute`, field 1.
473    pub start_minute: u8,
474    /// `EndHour`, field 2.
475    pub end_hour: u8,
476    /// `EndMinute`, field 3.
477    pub end_minute: u8,
478}
479
480impl ToTlv for TimePeriodStruct {
481    fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
482        w.start_structure(tag)?;
483        self.start_hour.to_tlv(w, Tag::Context(0))?;
484        self.start_minute.to_tlv(w, Tag::Context(1))?;
485        self.end_hour.to_tlv(w, Tag::Context(2))?;
486        self.end_minute.to_tlv(w, Tag::Context(3))?;
487        w.end_container()
488    }
489}
490
491impl<'a> FromTlv<'a> for TimePeriodStruct {
492    fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
493        if element.value.container() != Some(ContainerKind::Structure) {
494            return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
495        }
496        let mut start_hour = None;
497        let mut start_minute = None;
498        let mut end_hour = None;
499        let mut end_minute = None;
500        loop {
501            let Some(field) = reader.next_element()? else {
502                return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
503            };
504            if field.value == Value::EndOfContainer {
505                break;
506            }
507            match field.tag.context() {
508                Some(0) => start_hour = Some(<u8>::from_tlv(reader, &field)?),
509                Some(1) => start_minute = Some(<u8>::from_tlv(reader, &field)?),
510                Some(2) => end_hour = Some(<u8>::from_tlv(reader, &field)?),
511                Some(3) => end_minute = Some(<u8>::from_tlv(reader, &field)?),
512                // A field this revision does not define. §7.19.2: a receiver
513                // ignores what it does not know rather than refusing the whole
514                // structure, which is what lets a newer peer talk to an older one.
515                _ => reader.skip_value(&field)?,
516            }
517        }
518        Ok(Self {
519            start_hour: start_hour.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
520            start_minute: start_minute.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
521            end_hour: end_hour.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
522            end_minute: end_minute.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
523        })
524    }
525}
526
527/// `TimeWindowStruct`.
528#[derive(Debug, Clone, Copy, PartialEq)]
529pub struct TimeWindowStruct<'a> {
530    /// `TimeWindowIndex`, field 0.
531    pub time_window_index: Nullable<u16>,
532    /// `DayOfWeek`, field 1.
533    pub day_of_week: DayOfWeekBitmap,
534    /// `TimePeriod`, field 2.
535    pub time_period: TlvList<'a, TimePeriodStruct>,
536}
537
538impl<'a> ToTlv for TimeWindowStruct<'a> {
539    fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
540        w.start_structure(tag)?;
541        self.time_window_index.to_tlv(w, Tag::Context(0))?;
542        self.day_of_week.to_tlv(w, Tag::Context(1))?;
543        self.time_period.to_tlv(w, Tag::Context(2))?;
544        w.end_container()
545    }
546}
547
548impl<'a> FromTlv<'a> for TimeWindowStruct<'a> {
549    fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
550        if element.value.container() != Some(ContainerKind::Structure) {
551            return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
552        }
553        let mut time_window_index = None;
554        let mut day_of_week = None;
555        let mut time_period = None;
556        loop {
557            let Some(field) = reader.next_element()? else {
558                return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
559            };
560            if field.value == Value::EndOfContainer {
561                break;
562            }
563            match field.tag.context() {
564                Some(0) => time_window_index = Some(<Nullable<u16>>::from_tlv(reader, &field)?),
565                Some(1) => day_of_week = Some(<DayOfWeekBitmap>::from_tlv(reader, &field)?),
566                Some(2) => {
567                    time_period = Some(<TlvList<'a, TimePeriodStruct>>::from_tlv(reader, &field)?)
568                }
569                // A field this revision does not define. §7.19.2: a receiver
570                // ignores what it does not know rather than refusing the whole
571                // structure, which is what lets a newer peer talk to an older one.
572                _ => reader.skip_value(&field)?,
573            }
574        }
575        Ok(Self {
576            time_window_index: time_window_index
577                .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
578            day_of_week: day_of_week.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
579            time_period: time_period.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
580        })
581    }
582}
583
584/// The fields of `UpdatePIN` (command `0x00`).
585#[derive(Debug, Clone, Copy, PartialEq)]
586pub struct UpdatePINFields<'a> {
587    /// `OldPIN`, field 0.
588    pub old_pin: &'a str,
589    /// `NewPIN`, field 1.
590    pub new_pin: &'a str,
591}
592
593impl<'a> ToTlv for UpdatePINFields<'a> {
594    fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
595        w.start_structure(tag)?;
596        self.old_pin.to_tlv(w, Tag::Context(0))?;
597        self.new_pin.to_tlv(w, Tag::Context(1))?;
598        w.end_container()
599    }
600}
601
602impl<'a> FromTlv<'a> for UpdatePINFields<'a> {
603    fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
604        if element.value.container() != Some(ContainerKind::Structure) {
605            return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
606        }
607        let mut old_pin = None;
608        let mut new_pin = None;
609        loop {
610            let Some(field) = reader.next_element()? else {
611                return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
612            };
613            if field.value == Value::EndOfContainer {
614                break;
615            }
616            match field.tag.context() {
617                Some(0) => old_pin = Some(<&'a str>::from_tlv(reader, &field)?),
618                Some(1) => new_pin = Some(<&'a str>::from_tlv(reader, &field)?),
619                // A field this revision does not define. §7.19.2: a receiver
620                // ignores what it does not know rather than refusing the whole
621                // structure, which is what lets a newer peer talk to an older one.
622                _ => reader.skip_value(&field)?,
623            }
624        }
625        Ok(Self {
626            old_pin: old_pin.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
627            new_pin: new_pin.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
628        })
629    }
630}
631
632/// The fields of `ResetPINResponse` (command `0x02`).
633#[derive(Debug, Clone, Copy, PartialEq)]
634pub struct ResetPINResponseFields<'a> {
635    /// `PINCode`, field 0.
636    pub pin_code: &'a str,
637}
638
639impl<'a> ToTlv for ResetPINResponseFields<'a> {
640    fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
641        w.start_structure(tag)?;
642        self.pin_code.to_tlv(w, Tag::Context(0))?;
643        w.end_container()
644    }
645}
646
647impl<'a> FromTlv<'a> for ResetPINResponseFields<'a> {
648    fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
649        if element.value.container() != Some(ContainerKind::Structure) {
650            return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
651        }
652        let mut pin_code = None;
653        loop {
654            let Some(field) = reader.next_element()? else {
655                return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
656            };
657            if field.value == Value::EndOfContainer {
658                break;
659            }
660            match field.tag.context() {
661                Some(0) => pin_code = Some(<&'a str>::from_tlv(reader, &field)?),
662                // A field this revision does not define. §7.19.2: a receiver
663                // ignores what it does not know rather than refusing the whole
664                // structure, which is what lets a newer peer talk to an older one.
665                _ => reader.skip_value(&field)?,
666            }
667        }
668        Ok(Self {
669            pin_code: pin_code.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
670        })
671    }
672}
673
674/// The fields of `AddBonusTime` (command `0x05`).
675#[derive(Debug, Clone, Copy, PartialEq)]
676pub struct AddBonusTimeFields<'a> {
677    /// `PINCode`, field 0.
678    pub pin_code: Option<&'a str>,
679    /// `BonusTime`, field 1.
680    pub bonus_time: u32,
681}
682
683impl<'a> ToTlv for AddBonusTimeFields<'a> {
684    fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
685        w.start_structure(tag)?;
686        if let Some(value) = &self.pin_code {
687            value.to_tlv(w, Tag::Context(0))?;
688        }
689        self.bonus_time.to_tlv(w, Tag::Context(1))?;
690        w.end_container()
691    }
692}
693
694impl<'a> FromTlv<'a> for AddBonusTimeFields<'a> {
695    fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
696        if element.value.container() != Some(ContainerKind::Structure) {
697            return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
698        }
699        let mut pin_code = None;
700        let mut bonus_time = None;
701        loop {
702            let Some(field) = reader.next_element()? else {
703                return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
704            };
705            if field.value == Value::EndOfContainer {
706                break;
707            }
708            match field.tag.context() {
709                Some(0) => pin_code = Some(<&'a str>::from_tlv(reader, &field)?),
710                Some(1) => bonus_time = Some(<u32>::from_tlv(reader, &field)?),
711                // A field this revision does not define. §7.19.2: a receiver
712                // ignores what it does not know rather than refusing the whole
713                // structure, which is what lets a newer peer talk to an older one.
714                _ => reader.skip_value(&field)?,
715            }
716        }
717        Ok(Self {
718            pin_code,
719            bonus_time: bonus_time.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
720        })
721    }
722}
723
724/// The fields of `SetScreenDailyTime` (command `0x06`).
725#[derive(Debug, Clone, Copy, PartialEq)]
726pub struct SetScreenDailyTimeFields {
727    /// `ScreenTime`, field 0.
728    pub screen_time: u32,
729}
730
731impl ToTlv for SetScreenDailyTimeFields {
732    fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
733        w.start_structure(tag)?;
734        self.screen_time.to_tlv(w, Tag::Context(0))?;
735        w.end_container()
736    }
737}
738
739impl<'a> FromTlv<'a> for SetScreenDailyTimeFields {
740    fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
741        if element.value.container() != Some(ContainerKind::Structure) {
742            return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
743        }
744        let mut screen_time = None;
745        loop {
746            let Some(field) = reader.next_element()? else {
747                return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
748            };
749            if field.value == Value::EndOfContainer {
750                break;
751            }
752            match field.tag.context() {
753                Some(0) => screen_time = Some(<u32>::from_tlv(reader, &field)?),
754                // A field this revision does not define. §7.19.2: a receiver
755                // ignores what it does not know rather than refusing the whole
756                // structure, which is what lets a newer peer talk to an older one.
757                _ => reader.skip_value(&field)?,
758            }
759        }
760        Ok(Self {
761            screen_time: screen_time.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
762        })
763    }
764}
765
766/// The fields of `SetOnDemandRatingThreshold` (command `0x09`).
767#[derive(Debug, Clone, Copy, PartialEq)]
768pub struct SetOnDemandRatingThresholdFields<'a> {
769    /// `Rating`, field 0.
770    pub rating: &'a str,
771}
772
773impl<'a> ToTlv for SetOnDemandRatingThresholdFields<'a> {
774    fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
775        w.start_structure(tag)?;
776        self.rating.to_tlv(w, Tag::Context(0))?;
777        w.end_container()
778    }
779}
780
781impl<'a> FromTlv<'a> for SetOnDemandRatingThresholdFields<'a> {
782    fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
783        if element.value.container() != Some(ContainerKind::Structure) {
784            return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
785        }
786        let mut rating = None;
787        loop {
788            let Some(field) = reader.next_element()? else {
789                return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
790            };
791            if field.value == Value::EndOfContainer {
792                break;
793            }
794            match field.tag.context() {
795                Some(0) => rating = Some(<&'a str>::from_tlv(reader, &field)?),
796                // A field this revision does not define. §7.19.2: a receiver
797                // ignores what it does not know rather than refusing the whole
798                // structure, which is what lets a newer peer talk to an older one.
799                _ => reader.skip_value(&field)?,
800            }
801        }
802        Ok(Self {
803            rating: rating.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
804        })
805    }
806}
807
808/// The fields of `SetScheduledContentRatingThreshold` (command `0x0A`).
809#[derive(Debug, Clone, Copy, PartialEq)]
810pub struct SetScheduledContentRatingThresholdFields<'a> {
811    /// `Rating`, field 0.
812    pub rating: &'a str,
813}
814
815impl<'a> ToTlv for SetScheduledContentRatingThresholdFields<'a> {
816    fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
817        w.start_structure(tag)?;
818        self.rating.to_tlv(w, Tag::Context(0))?;
819        w.end_container()
820    }
821}
822
823impl<'a> FromTlv<'a> for SetScheduledContentRatingThresholdFields<'a> {
824    fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
825        if element.value.container() != Some(ContainerKind::Structure) {
826            return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
827        }
828        let mut rating = None;
829        loop {
830            let Some(field) = reader.next_element()? else {
831                return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
832            };
833            if field.value == Value::EndOfContainer {
834                break;
835            }
836            match field.tag.context() {
837                Some(0) => rating = Some(<&'a str>::from_tlv(reader, &field)?),
838                // A field this revision does not define. §7.19.2: a receiver
839                // ignores what it does not know rather than refusing the whole
840                // structure, which is what lets a newer peer talk to an older one.
841                _ => reader.skip_value(&field)?,
842            }
843        }
844        Ok(Self {
845            rating: rating.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
846        })
847    }
848}
849
850/// The fields of `AddBlockChannels` (command `0x0B`).
851#[derive(Debug, Clone, Copy, PartialEq)]
852pub struct AddBlockChannelsFields<'a> {
853    /// `Channels`, field 0.
854    pub channels: TlvList<'a, BlockChannelStruct<'a>>,
855}
856
857impl<'a> ToTlv for AddBlockChannelsFields<'a> {
858    fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
859        w.start_structure(tag)?;
860        self.channels.to_tlv(w, Tag::Context(0))?;
861        w.end_container()
862    }
863}
864
865impl<'a> FromTlv<'a> for AddBlockChannelsFields<'a> {
866    fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
867        if element.value.container() != Some(ContainerKind::Structure) {
868            return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
869        }
870        let mut channels = None;
871        loop {
872            let Some(field) = reader.next_element()? else {
873                return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
874            };
875            if field.value == Value::EndOfContainer {
876                break;
877            }
878            match field.tag.context() {
879                Some(0) => {
880                    channels = Some(<TlvList<'a, BlockChannelStruct<'a>>>::from_tlv(
881                        reader, &field,
882                    )?)
883                }
884                // A field this revision does not define. §7.19.2: a receiver
885                // ignores what it does not know rather than refusing the whole
886                // structure, which is what lets a newer peer talk to an older one.
887                _ => reader.skip_value(&field)?,
888            }
889        }
890        Ok(Self {
891            channels: channels.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
892        })
893    }
894}
895
896/// The fields of `RemoveBlockChannels` (command `0x0C`).
897#[derive(Debug, Clone, Copy, PartialEq)]
898pub struct RemoveBlockChannelsFields<'a> {
899    /// `ChannelIndexes`, field 0.
900    pub channel_indexes: TlvList<'a, u16>,
901}
902
903impl<'a> ToTlv for RemoveBlockChannelsFields<'a> {
904    fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
905        w.start_structure(tag)?;
906        self.channel_indexes.to_tlv(w, Tag::Context(0))?;
907        w.end_container()
908    }
909}
910
911impl<'a> FromTlv<'a> for RemoveBlockChannelsFields<'a> {
912    fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
913        if element.value.container() != Some(ContainerKind::Structure) {
914            return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
915        }
916        let mut channel_indexes = None;
917        loop {
918            let Some(field) = reader.next_element()? else {
919                return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
920            };
921            if field.value == Value::EndOfContainer {
922                break;
923            }
924            match field.tag.context() {
925                Some(0) => channel_indexes = Some(<TlvList<'a, u16>>::from_tlv(reader, &field)?),
926                // A field this revision does not define. §7.19.2: a receiver
927                // ignores what it does not know rather than refusing the whole
928                // structure, which is what lets a newer peer talk to an older one.
929                _ => reader.skip_value(&field)?,
930            }
931        }
932        Ok(Self {
933            channel_indexes: channel_indexes
934                .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
935        })
936    }
937}
938
939/// The fields of `AddBlockApplications` (command `0x0D`).
940#[derive(Debug, Clone, Copy, PartialEq)]
941pub struct AddBlockApplicationsFields<'a> {
942    /// `Applications`, field 0.
943    pub applications: TlvList<'a, AppInfoStruct<'a>>,
944}
945
946impl<'a> ToTlv for AddBlockApplicationsFields<'a> {
947    fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
948        w.start_structure(tag)?;
949        self.applications.to_tlv(w, Tag::Context(0))?;
950        w.end_container()
951    }
952}
953
954impl<'a> FromTlv<'a> for AddBlockApplicationsFields<'a> {
955    fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
956        if element.value.container() != Some(ContainerKind::Structure) {
957            return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
958        }
959        let mut applications = None;
960        loop {
961            let Some(field) = reader.next_element()? else {
962                return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
963            };
964            if field.value == Value::EndOfContainer {
965                break;
966            }
967            match field.tag.context() {
968                Some(0) => {
969                    applications = Some(<TlvList<'a, AppInfoStruct<'a>>>::from_tlv(reader, &field)?)
970                }
971                // A field this revision does not define. §7.19.2: a receiver
972                // ignores what it does not know rather than refusing the whole
973                // structure, which is what lets a newer peer talk to an older one.
974                _ => reader.skip_value(&field)?,
975            }
976        }
977        Ok(Self {
978            applications: applications.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
979        })
980    }
981}
982
983/// The fields of `RemoveBlockApplications` (command `0x0E`).
984#[derive(Debug, Clone, Copy, PartialEq)]
985pub struct RemoveBlockApplicationsFields<'a> {
986    /// `Applications`, field 0.
987    pub applications: TlvList<'a, AppInfoStruct<'a>>,
988}
989
990impl<'a> ToTlv for RemoveBlockApplicationsFields<'a> {
991    fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
992        w.start_structure(tag)?;
993        self.applications.to_tlv(w, Tag::Context(0))?;
994        w.end_container()
995    }
996}
997
998impl<'a> FromTlv<'a> for RemoveBlockApplicationsFields<'a> {
999    fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
1000        if element.value.container() != Some(ContainerKind::Structure) {
1001            return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
1002        }
1003        let mut applications = None;
1004        loop {
1005            let Some(field) = reader.next_element()? else {
1006                return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
1007            };
1008            if field.value == Value::EndOfContainer {
1009                break;
1010            }
1011            match field.tag.context() {
1012                Some(0) => {
1013                    applications = Some(<TlvList<'a, AppInfoStruct<'a>>>::from_tlv(reader, &field)?)
1014                }
1015                // A field this revision does not define. §7.19.2: a receiver
1016                // ignores what it does not know rather than refusing the whole
1017                // structure, which is what lets a newer peer talk to an older one.
1018                _ => reader.skip_value(&field)?,
1019            }
1020        }
1021        Ok(Self {
1022            applications: applications.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1023        })
1024    }
1025}
1026
1027/// The fields of `SetBlockContentTimeWindow` (command `0x0F`).
1028#[derive(Debug, Clone, Copy, PartialEq)]
1029pub struct SetBlockContentTimeWindowFields<'a> {
1030    /// `TimeWindow`, field 0.
1031    pub time_window: TimeWindowStruct<'a>,
1032}
1033
1034impl<'a> ToTlv for SetBlockContentTimeWindowFields<'a> {
1035    fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
1036        w.start_structure(tag)?;
1037        self.time_window.to_tlv(w, Tag::Context(0))?;
1038        w.end_container()
1039    }
1040}
1041
1042impl<'a> FromTlv<'a> for SetBlockContentTimeWindowFields<'a> {
1043    fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
1044        if element.value.container() != Some(ContainerKind::Structure) {
1045            return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
1046        }
1047        let mut time_window = None;
1048        loop {
1049            let Some(field) = reader.next_element()? else {
1050                return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
1051            };
1052            if field.value == Value::EndOfContainer {
1053                break;
1054            }
1055            match field.tag.context() {
1056                Some(0) => time_window = Some(<TimeWindowStruct<'a>>::from_tlv(reader, &field)?),
1057                // A field this revision does not define. §7.19.2: a receiver
1058                // ignores what it does not know rather than refusing the whole
1059                // structure, which is what lets a newer peer talk to an older one.
1060                _ => reader.skip_value(&field)?,
1061            }
1062        }
1063        Ok(Self {
1064            time_window: time_window.ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1065        })
1066    }
1067}
1068
1069/// The fields of `RemoveBlockContentTimeWindow` (command `0x10`).
1070#[derive(Debug, Clone, Copy, PartialEq)]
1071pub struct RemoveBlockContentTimeWindowFields<'a> {
1072    /// `TimeWindowIndexes`, field 0.
1073    pub time_window_indexes: TlvList<'a, u16>,
1074}
1075
1076impl<'a> ToTlv for RemoveBlockContentTimeWindowFields<'a> {
1077    fn to_tlv(&self, w: &mut TlvWriter<'_>, tag: Tag) -> Result<()> {
1078        w.start_structure(tag)?;
1079        self.time_window_indexes.to_tlv(w, Tag::Context(0))?;
1080        w.end_container()
1081    }
1082}
1083
1084impl<'a> FromTlv<'a> for RemoveBlockContentTimeWindowFields<'a> {
1085    fn from_tlv(reader: &mut TlvReader<'a>, element: &Element<'a>) -> Result<Self> {
1086        if element.value.container() != Some(ContainerKind::Structure) {
1087            return Err(crate::Error::new(crate::ErrorCode::TlvWrongType));
1088        }
1089        let mut time_window_indexes = None;
1090        loop {
1091            let Some(field) = reader.next_element()? else {
1092                return Err(crate::Error::new(crate::ErrorCode::TlvTruncated));
1093            };
1094            if field.value == Value::EndOfContainer {
1095                break;
1096            }
1097            match field.tag.context() {
1098                Some(0) => {
1099                    time_window_indexes = Some(<TlvList<'a, u16>>::from_tlv(reader, &field)?)
1100                }
1101                // A field this revision does not define. §7.19.2: a receiver
1102                // ignores what it does not know rather than refusing the whole
1103                // structure, which is what lets a newer peer talk to an older one.
1104                _ => reader.skip_value(&field)?,
1105            }
1106        }
1107        Ok(Self {
1108            time_window_indexes: time_window_indexes
1109                .ok_or(crate::Error::new(crate::ErrorCode::TlvNotFound))?,
1110        })
1111    }
1112}
1113
1114/// Every attribute the specification defines, with its conformance.
1115pub const ATTRIBUTES: &[Attribute] = &[
1116    Attribute {
1117        id: 0x0000,
1118        name: "Enabled",
1119        kind: "bool",
1120        access: Access::read_only(Privilege::View),
1121        qualities: AttributeQualities::empty(),
1122        reporting: Reporting::OnChange,
1123        conform: Conform::MANDATORY,
1124    },
1125    Attribute {
1126        id: 0x0001,
1127        name: "OnDemandRatings",
1128        kind: "list[RatingNameStruct]",
1129        access: Access::read_only(Privilege::View),
1130        qualities: AttributeQualities::empty(),
1131        reporting: Reporting::OnChange,
1132        conform: Conform {
1133            clauses: &[Clause {
1134                verdict: Conformance::Mandatory,
1135                when: Condition::Feature(3),
1136            }],
1137        },
1138    },
1139    Attribute {
1140        id: 0x0002,
1141        name: "OnDemandRatingThreshold",
1142        kind: "string",
1143        access: Access::read_only(Privilege::View),
1144        qualities: AttributeQualities::empty(),
1145        reporting: Reporting::OnChange,
1146        conform: Conform {
1147            clauses: &[Clause {
1148                verdict: Conformance::Mandatory,
1149                when: Condition::Feature(3),
1150            }],
1151        },
1152    },
1153    Attribute {
1154        id: 0x0003,
1155        name: "ScheduledContentRatings",
1156        kind: "list[RatingNameStruct]",
1157        access: Access::read_only(Privilege::View),
1158        qualities: AttributeQualities::empty(),
1159        reporting: Reporting::OnChange,
1160        conform: Conform {
1161            clauses: &[Clause {
1162                verdict: Conformance::Mandatory,
1163                when: Condition::Feature(4),
1164            }],
1165        },
1166    },
1167    Attribute {
1168        id: 0x0004,
1169        name: "ScheduledContentRatingThreshold",
1170        kind: "string",
1171        access: Access::read_only(Privilege::View),
1172        qualities: AttributeQualities::empty(),
1173        reporting: Reporting::OnChange,
1174        conform: Conform {
1175            clauses: &[Clause {
1176                verdict: Conformance::Mandatory,
1177                when: Condition::Feature(4),
1178            }],
1179        },
1180    },
1181    Attribute {
1182        id: 0x0005,
1183        name: "ScreenDailyTime",
1184        kind: "elapsed-s",
1185        access: Access::read_only(Privilege::View),
1186        qualities: AttributeQualities::empty(),
1187        reporting: Reporting::OnChange,
1188        conform: Conform {
1189            clauses: &[Clause {
1190                verdict: Conformance::Mandatory,
1191                when: Condition::Feature(0),
1192            }],
1193        },
1194    },
1195    Attribute {
1196        id: 0x0006,
1197        name: "RemainingScreenTime",
1198        kind: "elapsed-s",
1199        access: Access::read_only(Privilege::View),
1200        qualities: AttributeQualities::empty(),
1201        reporting: Reporting::OnChange,
1202        conform: Conform {
1203            clauses: &[Clause {
1204                verdict: Conformance::Mandatory,
1205                when: Condition::Feature(0),
1206            }],
1207        },
1208    },
1209    Attribute {
1210        id: 0x0007,
1211        name: "BlockUnrated",
1212        kind: "bool",
1213        access: Access::read_only(Privilege::View),
1214        qualities: AttributeQualities::empty(),
1215        reporting: Reporting::OnChange,
1216        conform: Conform {
1217            clauses: &[Clause {
1218                verdict: Conformance::Mandatory,
1219                when: Condition::Feature(2),
1220            }],
1221        },
1222    },
1223    Attribute {
1224        id: 0x0008,
1225        name: "BlockChannelList",
1226        kind: "list[BlockChannelStruct]",
1227        access: Access::read_only(Privilege::View),
1228        qualities: AttributeQualities::empty(),
1229        reporting: Reporting::OnChange,
1230        conform: Conform {
1231            clauses: &[Clause {
1232                verdict: Conformance::Mandatory,
1233                when: Condition::Feature(5),
1234            }],
1235        },
1236    },
1237    Attribute {
1238        id: 0x0009,
1239        name: "BlockApplicationList",
1240        kind: "list[AppInfoStruct]",
1241        access: Access::read_only(Privilege::View),
1242        qualities: AttributeQualities::empty(),
1243        reporting: Reporting::OnChange,
1244        conform: Conform {
1245            clauses: &[Clause {
1246                verdict: Conformance::Mandatory,
1247                when: Condition::Feature(6),
1248            }],
1249        },
1250    },
1251    Attribute {
1252        id: 0x000A,
1253        name: "BlockContentTimeWindow",
1254        kind: "list[TimeWindowStruct]",
1255        access: Access::read_only(Privilege::View),
1256        qualities: AttributeQualities::empty(),
1257        reporting: Reporting::OnChange,
1258        conform: Conform {
1259            clauses: &[Clause {
1260                verdict: Conformance::Mandatory,
1261                when: Condition::Feature(7),
1262            }],
1263        },
1264    },
1265];
1266
1267/// Every command, with its conformance.
1268pub const COMMANDS: &[Command] = &[
1269    Command {
1270        id: 0x00,
1271        name: "UpdatePIN",
1272        to_server: true,
1273        response: None,
1274        access: Access::invoke(Privilege::Manage).with_qualities(AccessQualities::TIMED),
1275        conform: Conform {
1276            clauses: &[Clause {
1277                verdict: Conformance::Mandatory,
1278                when: Condition::Feature(1),
1279            }],
1280        },
1281    },
1282    Command {
1283        id: 0x01,
1284        name: "ResetPIN",
1285        to_server: true,
1286        response: Some(0x02),
1287        access: Access::invoke(Privilege::Administer).with_qualities(AccessQualities::TIMED),
1288        conform: Conform {
1289            clauses: &[Clause {
1290                verdict: Conformance::Mandatory,
1291                when: Condition::Feature(1),
1292            }],
1293        },
1294    },
1295    Command {
1296        id: 0x02,
1297        name: "ResetPINResponse",
1298        to_server: false,
1299        response: None,
1300        access: Access::invoke(Privilege::Operate),
1301        conform: Conform {
1302            clauses: &[Clause {
1303                verdict: Conformance::Mandatory,
1304                when: Condition::Feature(1),
1305            }],
1306        },
1307    },
1308    Command {
1309        id: 0x03,
1310        name: "Enable",
1311        to_server: true,
1312        response: None,
1313        access: Access::invoke(Privilege::Manage).with_qualities(AccessQualities::TIMED),
1314        conform: Conform::MANDATORY,
1315    },
1316    Command {
1317        id: 0x04,
1318        name: "Disable",
1319        to_server: true,
1320        response: None,
1321        access: Access::invoke(Privilege::Manage).with_qualities(AccessQualities::TIMED),
1322        conform: Conform::MANDATORY,
1323    },
1324    Command {
1325        id: 0x05,
1326        name: "AddBonusTime",
1327        to_server: true,
1328        response: None,
1329        access: Access::invoke(Privilege::Operate),
1330        conform: Conform {
1331            clauses: &[Clause {
1332                verdict: Conformance::Mandatory,
1333                when: Condition::Feature(0),
1334            }],
1335        },
1336    },
1337    Command {
1338        id: 0x06,
1339        name: "SetScreenDailyTime",
1340        to_server: true,
1341        response: None,
1342        access: Access::invoke(Privilege::Manage),
1343        conform: Conform {
1344            clauses: &[Clause {
1345                verdict: Conformance::Mandatory,
1346                when: Condition::Feature(0),
1347            }],
1348        },
1349    },
1350    Command {
1351        id: 0x07,
1352        name: "BlockUnratedContent",
1353        to_server: true,
1354        response: None,
1355        access: Access::invoke(Privilege::Manage),
1356        conform: Conform {
1357            clauses: &[Clause {
1358                verdict: Conformance::Mandatory,
1359                when: Condition::Feature(2),
1360            }],
1361        },
1362    },
1363    Command {
1364        id: 0x08,
1365        name: "UnblockUnratedContent",
1366        to_server: true,
1367        response: None,
1368        access: Access::invoke(Privilege::Manage),
1369        conform: Conform {
1370            clauses: &[Clause {
1371                verdict: Conformance::Mandatory,
1372                when: Condition::Feature(2),
1373            }],
1374        },
1375    },
1376    Command {
1377        id: 0x09,
1378        name: "SetOnDemandRatingThreshold",
1379        to_server: true,
1380        response: None,
1381        access: Access::invoke(Privilege::Manage),
1382        conform: Conform {
1383            clauses: &[Clause {
1384                verdict: Conformance::Mandatory,
1385                when: Condition::Feature(3),
1386            }],
1387        },
1388    },
1389    Command {
1390        id: 0x0A,
1391        name: "SetScheduledContentRatingThreshold",
1392        to_server: true,
1393        response: None,
1394        access: Access::invoke(Privilege::Manage),
1395        conform: Conform {
1396            clauses: &[Clause {
1397                verdict: Conformance::Mandatory,
1398                when: Condition::Feature(4),
1399            }],
1400        },
1401    },
1402    Command {
1403        id: 0x0B,
1404        name: "AddBlockChannels",
1405        to_server: true,
1406        response: None,
1407        access: Access::invoke(Privilege::Manage),
1408        conform: Conform {
1409            clauses: &[Clause {
1410                verdict: Conformance::Mandatory,
1411                when: Condition::Feature(5),
1412            }],
1413        },
1414    },
1415    Command {
1416        id: 0x0C,
1417        name: "RemoveBlockChannels",
1418        to_server: true,
1419        response: None,
1420        access: Access::invoke(Privilege::Manage),
1421        conform: Conform {
1422            clauses: &[Clause {
1423                verdict: Conformance::Mandatory,
1424                when: Condition::Feature(5),
1425            }],
1426        },
1427    },
1428    Command {
1429        id: 0x0D,
1430        name: "AddBlockApplications",
1431        to_server: true,
1432        response: None,
1433        access: Access::invoke(Privilege::Manage),
1434        conform: Conform {
1435            clauses: &[Clause {
1436                verdict: Conformance::Mandatory,
1437                when: Condition::Feature(6),
1438            }],
1439        },
1440    },
1441    Command {
1442        id: 0x0E,
1443        name: "RemoveBlockApplications",
1444        to_server: true,
1445        response: None,
1446        access: Access::invoke(Privilege::Manage),
1447        conform: Conform {
1448            clauses: &[Clause {
1449                verdict: Conformance::Mandatory,
1450                when: Condition::Feature(6),
1451            }],
1452        },
1453    },
1454    Command {
1455        id: 0x0F,
1456        name: "SetBlockContentTimeWindow",
1457        to_server: true,
1458        response: None,
1459        access: Access::invoke(Privilege::Manage),
1460        conform: Conform {
1461            clauses: &[Clause {
1462                verdict: Conformance::Mandatory,
1463                when: Condition::Feature(7),
1464            }],
1465        },
1466    },
1467    Command {
1468        id: 0x10,
1469        name: "RemoveBlockContentTimeWindow",
1470        to_server: true,
1471        response: None,
1472        access: Access::invoke(Privilege::Manage),
1473        conform: Conform {
1474            clauses: &[Clause {
1475                verdict: Conformance::Mandatory,
1476                when: Condition::Feature(7),
1477            }],
1478        },
1479    },
1480];
1481
1482/// Every event, with its conformance.
1483pub const EVENTS: &[Event] = &[
1484    Event {
1485        id: 0x00,
1486        name: "RemainingScreenTimeExpired",
1487        priority: EventPriority::Info,
1488        access: Access::read_only(Privilege::View),
1489        conform: Conform {
1490            clauses: &[Clause {
1491                verdict: Conformance::Mandatory,
1492                when: Condition::Feature(0),
1493            }],
1494        },
1495    },
1496    Event {
1497        id: 0x01,
1498        name: "EnteringBlockContentTimeWindow",
1499        priority: EventPriority::Info,
1500        access: Access::read_only(Privilege::View),
1501        conform: Conform {
1502            clauses: &[Clause {
1503                verdict: Conformance::Mandatory,
1504                when: Condition::Feature(7),
1505            }],
1506        },
1507    },
1508];
1509
1510/// The whole cluster, as the specification defines it.
1511pub const CLUSTER: Cluster = Cluster {
1512    id: ID,
1513    name: "Content Control",
1514    revision: REVISION,
1515    pics: "CONCON",
1516    derived_from: None,
1517    features: FEATURES,
1518    attributes: ATTRIBUTES,
1519    commands: COMMANDS,
1520    events: EVENTS,
1521};