Skip to main content

matter_clusters/gen/
boolean_state.rs

1//! BooleanState cluster (0x0045).
2//! @generated by `cargo xtask codegen` — do not edit.
3
4#![allow(
5    clippy::all,
6    clippy::pedantic,
7    dead_code,
8    unreachable_pub,
9    unused_imports
10)]
11
12use crate::datatypes::SemanticTagStruct;
13use crate::error::ClusterError;
14use crate::types::Nullable;
15use matter_codec::{ContainerKind, Element, Tag, TlvReader, TlvWriter, Value};
16
17/// Cluster ID.
18pub const CLUSTER_ID: u32 = 0x0045;
19/// Cluster revision.
20pub const CLUSTER_REVISION: u16 = 2;
21
22/// Command IDs (requests and responses).
23pub mod command_id {}
24
25/// Attribute IDs (cluster-specific).
26pub mod attribute_id {
27    /// `StateValue`.
28    pub const STATE_VALUE: u32 = 0x0000;
29}
30
31/// Decode the `StateValue` attribute value.
32///
33/// # Errors
34/// Returns [`ClusterError`] on a type mismatch or out-of-range value.
35pub fn decode_state_value(tlv: &[u8]) -> Result<bool, ClusterError> {
36    let mut r = TlvReader::new(tlv);
37    match r.next()? {
38        Some(Element::Scalar {
39            value: Value::Bool(v),
40            ..
41        }) => Ok(v),
42        _ => Err(ClusterError::UnexpectedType {
43            context: "StateValue",
44        }),
45    }
46}