pub struct Cluster {
pub id: ClusterId,
pub name: &'static str,
pub revision: u16,
pub pics: &'static str,
pub derived_from: Option<&'static str>,
pub features: &'static [Feature],
pub attributes: &'static [Attribute],
pub commands: &'static [Command],
pub events: &'static [Event],
}Expand description
A whole cluster, as the specification defines it.
Fields§
§id: ClusterIdIts id.
name: &'static strThe readable name — “On/Off”.
revision: u16The highest revision in the cluster’s revision history, which is what
ClusterRevision must report (§7.13.1).
pics: &'static strThe PICS code, for the certification declaration a test harness reads.
derived_from: Option<&'static str>Whether this cluster is a base or is derived from another — the Mode Base family and the Resource Monitoring clusters are one element set behind many ids.
features: &'static [Feature]Its FeatureMap bits.
attributes: &'static [Attribute]Every attribute it defines, sorted by id.
commands: &'static [Command]Every command, accepted and generated, sorted by id.
events: &'static [Event]Every event, sorted by id.
Implementations§
Source§impl Cluster
impl Cluster
Sourcepub fn feature_mask(&self) -> u32
pub fn feature_mask(&self) -> u32
The feature bits this revision defines, as a mask.
Sourcepub fn feature(&self, code: &str) -> Option<&Feature>
pub fn feature(&self, code: &str) -> Option<&Feature>
The feature whose code is code, if this cluster has one.
Sourcepub fn validate(
&self,
descriptor: &ClusterDescriptor<'_>,
found: impl FnMut(Defect),
)
pub fn validate( &self, descriptor: &ClusterDescriptor<'_>, found: impl FnMut(Defect), )
Checks a device’s descriptor against the specification, reporting each defect to
found.
Four kinds of mistake, and the first two are the ones a device makes by accident:
- a mandatory element missing — the feature map claims
Lightingand the descriptor has noStartUpOnOff; - a disallowed element present —
StartUpOnOffserved withoutLighting, which a commissioner reads as a device that does not know what it is; - a feature bit this revision does not define;
- a
ClusterRevisionthat is not the specification’s.
Elements whose conformance is prose are skipped in both directions. The specification could not express the rule mechanically, so neither can this — and guessing would produce exactly the confident-and-wrong answer that makes a validator worth ignoring.
A fifth is reported only on a build without the provisional feature: an element the
specification marks P, or a cluster one of the three provisional lists names
(PROVISIONAL_CLUSTERS).
Sourcepub fn is_valid(&self, descriptor: &ClusterDescriptor<'_>) -> bool
pub fn is_valid(&self, descriptor: &ClusterDescriptor<'_>) -> bool
Whether a descriptor has no defects at all.