matter_clusters/gen/
switch.rs1#![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
17pub const CLUSTER_ID: u32 = 0x003B;
19pub const CLUSTER_REVISION: u16 = 2;
21
22pub mod command_id {}
24
25pub mod attribute_id {
27 pub const NUMBER_OF_POSITIONS: u32 = 0x0000;
29 pub const CURRENT_POSITION: u32 = 0x0001;
31 pub const MULTI_PRESS_MAX: u32 = 0x0002;
33}
34
35bitflags::bitflags! {
36 #[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
38 pub struct Feature: u32 {
39 const LS = 1 << 0;
41 const MS = 1 << 1;
43 const MSR = 1 << 2;
45 const MSL = 1 << 3;
47 const MSM = 1 << 4;
49 const AS = 1 << 5;
51 }
52}
53
54pub fn decode_number_of_positions(tlv: &[u8]) -> Result<u8, ClusterError> {
59 let mut r = TlvReader::new(tlv);
60 match r.next()? {
61 Some(Element::Scalar {
62 value: Value::Uint(v),
63 ..
64 }) => Ok(u8::try_from(v).map_err(|_| ClusterError::InvalidLength("NumberOfPositions"))?),
65 _ => Err(ClusterError::UnexpectedType {
66 context: "NumberOfPositions",
67 }),
68 }
69}
70
71pub fn decode_current_position(tlv: &[u8]) -> Result<u8, ClusterError> {
76 let mut r = TlvReader::new(tlv);
77 match r.next()? {
78 Some(Element::Scalar {
79 value: Value::Uint(v),
80 ..
81 }) => Ok(u8::try_from(v).map_err(|_| ClusterError::InvalidLength("CurrentPosition"))?),
82 _ => Err(ClusterError::UnexpectedType {
83 context: "CurrentPosition",
84 }),
85 }
86}
87
88pub fn decode_multi_press_max(tlv: &[u8]) -> Result<u8, ClusterError> {
93 let mut r = TlvReader::new(tlv);
94 match r.next()? {
95 Some(Element::Scalar {
96 value: Value::Uint(v),
97 ..
98 }) => Ok(u8::try_from(v).map_err(|_| ClusterError::InvalidLength("MultiPressMax"))?),
99 _ => Err(ClusterError::UnexpectedType {
100 context: "MultiPressMax",
101 }),
102 }
103}