pub struct ClusterDescriptor<'a> {
pub id: ClusterId,
pub revision: u16,
pub feature_map: u32,
pub attributes: &'a [AttributeDescriptor],
pub accepted_commands: &'a [CommandDescriptor],
pub generated_commands: &'a [CommandId],
pub events: &'a [EventDescriptor],
}Expand description
What a cluster instance looks like (§7.10).
Static: this is the cluster’s shape, which does not change at runtime. The attribute,
command and event slices are expected to be const arrays in flash, and to be sorted
by id — ClusterDescriptor::attribute and its siblings binary-search them, and
§7.13’s synthesised lists are emitted in that order.
Fields§
§id: ClusterIdThe cluster id.
revision: u16ClusterRevision (§7.13.1) — “the (highest) revision number of the cluster
specification that has been implemented”, and never zero for a cluster defined after
the attribute existed.
feature_map: u32FeatureMap (§7.13.2). Zero “for a cluster whose definition does not define a
FeatureMap”.
attributes: &'a [AttributeDescriptor]The attributes this instance serves, excluding the global ones of §7.13, sorted by id.
accepted_commands: &'a [CommandDescriptor]The client-to-server commands it accepts, sorted by id.
generated_commands: &'a [CommandId]The server-to-client commands it generates that are not responses to an accepted
command — most clusters have none, because responses are derived from
CommandDescriptor::response.
events: &'a [EventDescriptor]The events it may emit, sorted by id.
Implementations§
Source§impl<'a> ClusterDescriptor<'a>
impl<'a> ClusterDescriptor<'a>
Sourcepub fn attribute(&self, id: AttributeId) -> Option<AttributeDescriptor>
pub fn attribute(&self, id: AttributeId) -> Option<AttributeDescriptor>
The descriptor for an attribute id, including the global ones of §7.13.
Sourcepub fn accepted_command(&self, id: CommandId) -> Option<CommandDescriptor>
pub fn accepted_command(&self, id: CommandId) -> Option<CommandDescriptor>
The descriptor for an accepted command id.
Sourcepub fn event(&self, id: EventId) -> Option<EventDescriptor>
pub fn event(&self, id: EventId) -> Option<EventDescriptor>
The descriptor for an event id.
Sourcepub fn attribute_ids(&self) -> impl Iterator<Item = AttributeId> + 'a
pub fn attribute_ids(&self) -> impl Iterator<Item = AttributeId> + 'a
Every attribute id this instance serves, in ascending order: the cluster’s own, then §7.13’s globals.
This is AttributeList’s content. The globals sort last because their ids are
0xFFF8–0xFFFD, above any cluster-specific id.
Sourcepub fn generated_command_ids(&self) -> impl Iterator<Item = CommandId> + 'a
pub fn generated_command_ids(&self) -> impl Iterator<Item = CommandId> + 'a
Every command id the server may generate: each accepted command’s response, plus any declared outright.
§7.13.5: “For each command in this list that is a response to a client request command, the request command SHALL be indicated in the AcceptedCommandList” — which is exactly the relation this derives from, so the two lists cannot disagree.
Sourcepub fn is_well_formed(&self) -> bool
pub fn is_well_formed(&self) -> bool
Whether the descriptor is well formed: every slice sorted and free of duplicates, and no attribute claiming an id §7.13 reserves for a global.
A const node cannot be validated at compile time today, so this is what
Node::validate calls — once, at start-up, rather than
per request. An unsorted slice would make the binary searches silently miss.