pub struct Conforming<const A: usize, const C: usize, const G: usize, const E: usize> { /* private fields */ }Expand description
A ClusterDescriptor derived from the specification’s own tables.
The tables say which elements a feature map makes mandatory and which it forbids, so a
device that states its features and its optional choices does not need to write the lists
out — and cannot get them wrong. That is the failure this exists for: a hand-written
descriptor whose element list does not move when its feature map does still advertises
the elements, and a client reading AttributeList believes it.
A, C, G and E bound what the device holds — the attributes, accepted commands,
generated commands and events conformance selected, not the size of the specification’s
table. Sizing one too small is NoSpace, at construction,
once.
use matter_kit::clusters::generated::on_off;
use matter_kit::dm::spec::{Conforming, Optional};
// A plain On/Off server: no Lighting, so none of its four attributes.
let plain = Conforming::<8, 8, 4, 4>::new(&on_off::CLUSTER, 0, &Optional::NONE)?;
assert_eq!(plain.descriptor().attributes.len(), 1);
// The same cluster with Lighting: `StartUpOnOff` and its three companions appear, and so
// do three more commands, without a line of it being written down anywhere.
let lighting =
Conforming::<8, 8, 4, 4>::new(&on_off::CLUSTER, on_off::feature::LIGHTING, &Optional::NONE)?;
assert_eq!(lighting.descriptor().attributes.len(), 5);
assert_eq!(lighting.descriptor().accepted_commands.len(), 6);Implementations§
Source§impl<const A: usize, const C: usize, const G: usize, const E: usize> Conforming<A, C, G, E>
impl<const A: usize, const C: usize, const G: usize, const E: usize> Conforming<A, C, G, E>
Sourcepub fn new(
spec: &'static Cluster,
feature_map: u32,
optional: &Optional<'_>,
) -> Result<Self>
pub fn new( spec: &'static Cluster, feature_map: u32, optional: &Optional<'_>, ) -> Result<Self>
Derives the descriptor for an instance of spec with this feature map.
Returns InvalidArgument for a feature bit the cluster does not define —
a device claiming one is describing a cluster that does not exist — and
NoSpace when a const parameter is too small for what conformance
selected.
Sourcepub fn descriptor(&self) -> ClusterDescriptor<'_>
pub fn descriptor(&self) -> ClusterDescriptor<'_>
The descriptor, borrowed from this storage.