Skip to main content

Conforming

Struct Conforming 

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

Source

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.

Source

pub fn descriptor(&self) -> ClusterDescriptor<'_>

The descriptor, borrowed from this storage.

Trait Implementations§

Source§

impl<const A: usize, const C: usize, const G: usize, const E: usize> Debug for Conforming<A, C, G, E>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<const A: usize, const C: usize, const G: usize, const E: usize> Forget for Conforming<A, C, G, E>

§

impl<const A: usize, const C: usize, const G: usize, const E: usize> Freeze for Conforming<A, C, G, E>

§

impl<const A: usize, const C: usize, const G: usize, const E: usize> Move for Conforming<A, C, G, E>

§

impl<const A: usize, const C: usize, const G: usize, const E: usize> RefUnwindSafe for Conforming<A, C, G, E>

§

impl<const A: usize, const C: usize, const G: usize, const E: usize> Send for Conforming<A, C, G, E>

§

impl<const A: usize, const C: usize, const G: usize, const E: usize> Sync for Conforming<A, C, G, E>

§

impl<const A: usize, const C: usize, const G: usize, const E: usize> Unpin for Conforming<A, C, G, E>

§

impl<const A: usize, const C: usize, const G: usize, const E: usize> UnsafeUnpin for Conforming<A, C, G, E>

§

impl<const A: usize, const C: usize, const G: usize, const E: usize> UnwindSafe for Conforming<A, C, G, E>

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> 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, 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.