matter-kit 0.3.0

Matter (CSA smart-home standard) protocol implementation in Rust: no_std, no-alloc, executor-agnostic
Documentation
// Generated by `cargo xtask` from the CSA data model 1.6. Do not edit.
//
// Power Topology — cluster 0x009C.
//
// Regenerate with `cargo xtask clusters --dm <checkout>/data_model/1.6`; `cargo xtask check`
// is the CI gate that keeps this file honest. The XML itself is not vendored here — it
// carries the CSA's own copyright notice and is not redistributable.

//! Power Topology (cluster `0x009C`, revision 1).
//!
//! 2 identifiers, 4 feature bits, and the specification's own conformance for
//! every element. `CLUSTER` is the whole table.

#![allow(unused_imports)]

use crate::dm::conformance::{Clause, Condition, Conform, Conformance};
use crate::dm::meta::{EventPriority, Reporting};
use crate::dm::spec::{Attribute, Cluster, Command, Event, Feature};
use crate::dm::{Access, AccessQualities, AttributeQualities, Privilege};
use crate::error::Result;
use crate::im::{AttributeId, ClusterId, CommandId, EventId};
use crate::tlv::{
    ContainerKind, Element, FromTlv, Nullable, Tag, TlvList, TlvReader, TlvWriter, ToTlv, Value,
};

/// The cluster id.
pub const ID: ClusterId = 0x009C;

/// The highest revision the specification's history defines — what `ClusterRevision`
/// must report (Core §7.13.1).
pub const REVISION: u16 = 1;

/// The PICS code, which a certification declaration names the cluster by.
pub const PICS: &str = "PWRTL";

/// The `FeatureMap` bits (Core §7.13.2).
///
/// A feature has conformance of its own: a device may not claim one the
/// specification forbids it alongside another.
pub mod feature {
    /// This endpoint provides or consumes power to/from the entire node
    ///
    /// Code `NODE`, bit 0.
    pub const NODE_TOPOLOGY: u32 = 1 << 0;
    /// This endpoint provides or consumes power to/from itself and its child endpoints
    ///
    /// Code `TREE`, bit 1.
    pub const TREE_TOPOLOGY: u32 = 1 << 1;
    /// This endpoint provides or consumes power to/from a specified set of endpoints
    ///
    /// Code `SET`, bit 2.
    pub const SET_TOPOLOGY: u32 = 1 << 2;
    /// The specified set of endpoints may change
    ///
    /// Code `DYPF`, bit 3.
    pub const DYNAMIC_POWER_FLOW: u32 = 1 << 3;
}

/// Every feature bit, with its conformance.
pub const FEATURES: &[Feature] = &[
    Feature {
        bit: 0,
        code: "NODE",
        name: "NodeTopology",
        conform: Conform::OPTIONAL,
    },
    Feature {
        bit: 1,
        code: "TREE",
        name: "TreeTopology",
        conform: Conform::OPTIONAL,
    },
    Feature {
        bit: 2,
        code: "SET",
        name: "SetTopology",
        conform: Conform::OPTIONAL,
    },
    Feature {
        bit: 3,
        code: "DYPF",
        name: "DynamicPowerFlow",
        conform: Conform {
            clauses: &[Clause {
                verdict: Conformance::Optional,
                when: Condition::Feature(2),
            }],
        },
    },
];

/// The attribute ids.
pub mod attribute {
    use crate::im::AttributeId;

    /// `AvailableEndpoints`.
    pub const AVAILABLE_ENDPOINTS: AttributeId = 0x00;
    /// `ActiveEndpoints`.
    pub const ACTIVE_ENDPOINTS: AttributeId = 0x01;
}

/// Every attribute the specification defines, with its conformance.
pub const ATTRIBUTES: &[Attribute] = &[
    Attribute {
        id: 0x0000,
        name: "AvailableEndpoints",
        kind: "list[endpoint-no]",
        access: Access::read_only(Privilege::View),
        qualities: AttributeQualities::FIXED,
        reporting: Reporting::OnChange,
        conform: Conform {
            clauses: &[Clause {
                verdict: Conformance::Mandatory,
                when: Condition::Feature(2),
            }],
        },
    },
    Attribute {
        id: 0x0001,
        name: "ActiveEndpoints",
        kind: "list[endpoint-no]",
        access: Access::read_only(Privilege::View),
        qualities: AttributeQualities::NON_VOLATILE,
        reporting: Reporting::OnChange,
        conform: Conform {
            clauses: &[Clause {
                verdict: Conformance::Mandatory,
                when: Condition::Feature(3),
            }],
        },
    },
];

/// Every command, with its conformance.
pub const COMMANDS: &[Command] = &[];

/// Every event, with its conformance.
pub const EVENTS: &[Event] = &[];

/// The whole cluster, as the specification defines it.
pub const CLUSTER: Cluster = Cluster {
    id: ID,
    name: "Power Topology",
    revision: REVISION,
    pics: "PWRTL",
    derived_from: None,
    features: FEATURES,
    attributes: ATTRIBUTES,
    commands: COMMANDS,
    events: EVENTS,
};