Skip to main content

zcl/types/
attribute.rs

1use crate::types::ZclType;
2
3#[derive(PartialEq, Debug, Copy, Clone)]
4pub enum ValueOrAttributeReference<T: ZclType> {
5    /// The value of another attribute on the same cluster
6    AttributeReference(u16),
7    /// An immediate value
8    Value(T),
9}
10
11#[derive(PartialEq, Debug, Copy, Clone)]
12pub enum AttributeRange<T: ZclType> {
13    // Any value but explicitly excluding the the NON_VALUE
14    Value,
15    // Any value. If a NON_VALUE is defined for the data type, it explicitly is interpreted as a
16    // normal value instead.
17    Full,
18    // Any value. If a NON_VALUE is defined for the data type, it will explicitly represent None.
19    FullWithNone,
20    // A range [min, max] where both boundary values are included
21    InclusiveRange(ValueOrAttributeReference<T>, ValueOrAttributeReference<T>),
22    // A maximum size in bytes.
23    Size(usize),
24}
25
26#[derive(PartialEq, Eq, Debug, Copy, Clone)]
27pub enum AttributeSide {
28    Server,
29    Client,
30    Either,
31}
32
33#[derive(PartialEq, Debug, Copy, Clone)]
34pub struct Attribute<'a, T: ZclType> {
35    pub code: u16,
36    pub name: &'a str,
37    pub side: AttributeSide,
38    pub readable: bool,
39    pub writable: bool,
40    pub reportable: bool,
41    pub scene: bool,
42    pub mandatory: bool,
43    pub default: Option<T>,
44    pub range: AttributeRange<T>,
45}