Skip to main content

Cluster

Struct Cluster 

Source
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: ClusterId

Its id.

§name: &'static str

The readable name — “On/Off”.

§revision: u16

The highest revision in the cluster’s revision history, which is what ClusterRevision must report (§7.13.1).

§pics: &'static str

The 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

Source

pub fn feature_mask(&self) -> u32

The feature bits this revision defines, as a mask.

Source

pub fn feature(&self, code: &str) -> Option<&Feature>

The feature whose code is code, if this cluster has one.

Source

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 Lighting and the descriptor has no StartUpOnOff;
  • a disallowed element present — StartUpOnOff served without Lighting, which a commissioner reads as a device that does not know what it is;
  • a feature bit this revision does not define;
  • a ClusterRevision that 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).

Source

pub fn is_valid(&self, descriptor: &ClusterDescriptor<'_>) -> bool

Whether a descriptor has no defects at all.

Trait Implementations§

Source§

impl Clone for Cluster

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Cluster

Source§

impl Debug for Cluster

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.