Skip to main content

ClusterHandler

Trait ClusterHandler 

Source
pub trait ClusterHandler {
    // Required method
    fn read(
        &self,
        resolved: &Resolved<'_>,
        ctx: &InteractionContext<'_>,
        w: &mut TlvWriter<'_>,
        tag: Tag,
    ) -> Result<(), Status>;

    // Provided methods
    fn data_version(&self, _resolved: &Resolved<'_>) -> Option<u32> { ... }
    fn write(
        &self,
        _resolved: &Resolved<'_>,
        _data: &[u8],
        _op: WriteOp,
        _ctx: &InteractionContext<'_>,
    ) -> Result<(), Status> { ... }
    fn invoke(
        &self,
        _resolved: &ResolvedCommand<'_>,
        _fields: Option<&[u8]>,
        _ctx: &InteractionContext<'_>,
        _w: &mut TlvWriter<'_>,
        _tag: Tag,
    ) -> Result<Option<CommandId>, StatusIb> { ... }
    fn on_lifecycle(&self, _event: Lifecycle) { ... }
}
Expand description

What a device’s clusters actually do.

One trait rather than three, because a device has one cluster implementation table and not three. Write and invoke have defaults that refuse, so a read-only node implements one method — and a cluster that forgets to implement write refuses writes rather than silently accepting them.

Every method returns a Status rather than an error, because §8.4.3.2, §8.7.3.2 and §8.8.2.3 all require one path’s failure to be reported for that path without failing the action. An error type would force the whole request to fail.

Required Methods§

Source

fn read( &self, resolved: &Resolved<'_>, ctx: &InteractionContext<'_>, w: &mut TlvWriter<'_>, tag: Tag, ) -> Result<(), Status>

Writes the value of resolved’s attribute under tag.

The global attributes of §7.13 never reach here: they are synthesised from the descriptor (dm::global), so a cluster does not implement its own ClusterRevision.

Provided Methods§

Source

fn data_version(&self, _resolved: &Resolved<'_>) -> Option<u32>

The cluster instance’s data version (§7.10.3), if it tracks one.

None omits the field, which a report may do; a client then cannot use a DataVersionFilter against that cluster, which costs bandwidth rather than correctness. It also means §8.7.3.2 step b.vi’s DATA_VERSION_MISMATCH check cannot fire, so a write is never rejected for staleness.

Source

fn write( &self, _resolved: &Resolved<'_>, _data: &[u8], _op: WriteOp, _ctx: &InteractionContext<'_>, ) -> Result<(), Status>

Writes data — the encoded TLV element, tag included — into the attribute.

op says how, and a cluster holding a list must honour it. §10.6.4.3.1 gives a client two ways to write a list, and they are told apart only by whether the path carries ListIndex: without it the data replaces the whole list, with it (null) the data is one more item to add. A cluster that ignores op and replaces on every block keeps only the last item of a list written item by item — which is how an access control list arrives, so the failure is a device that silently drops every ACL entry but one.

§8.7.3.3: a value outside the cluster’s constraints is CONSTRAINT_ERROR; a value that is well-typed but wrong for the device’s current state is Status::DynamicConstraintError. A list that cannot take another item is Status::ResourceExhausted.

Source

fn invoke( &self, _resolved: &ResolvedCommand<'_>, _fields: Option<&[u8]>, _ctx: &InteractionContext<'_>, _w: &mut TlvWriter<'_>, _tag: Tag, ) -> Result<Option<CommandId>, StatusIb>

Runs a command.

fields is the encoded CommandFields element, or None for a command that takes none. The three outcomes are exactly §8.8.2.3’s “Invoke Execution”:

  • Ok(None) — the command succeeded and the cluster defines no response command, so a CommandStatusIB with SUCCESS is generated.
  • Ok(Some(id)) — the cluster defines a response command; its fields have been written under tag and id is its command id.
  • Err(status) — a CommandStatusIB with that status.

The error is a StatusIb, not a bare Status, because §10.6.17 lets a cluster define its own codes alongside FAILURE — and some commands have no other way to report why they refused. §11.19’s OpenCommissioningWindow is the example: Busy, PAKEParameterError and WindowNotOpen are cluster-specific codes, and it has no response command to put them in. From<Status> makes the common case a ? away.

Source

fn on_lifecycle(&self, _event: Lifecycle)

Reacts to something that happened to the node (see Lifecycle).

The default does nothing, which is right for every cluster whose state is not scoped to a fabric and stages nothing under the fail-safe — most of them. There is no return value: nothing here can fail in a way a caller could act on, and a cluster that could not forget a fabric would have no way to keep it either.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<A: Cluster, B: Cluster, C: Cluster, D: Cluster, E: Cluster, F: Cluster, G: Cluster, H: Cluster, I: Cluster, J: Cluster, K: Cluster, L: Cluster> ClusterHandler for (A, B, C, D, E, F, G, H, I, J, K, L)

Source§

fn on_lifecycle(&self, event: Lifecycle)

Broadcast, not routed: a fabric going away is a fact about the node, and every cluster in the tuple is downstream of it.

Source§

fn read( &self, resolved: &Resolved<'_>, ctx: &InteractionContext<'_>, w: &mut TlvWriter<'_>, tag: Tag, ) -> Result<(), Status>

Source§

fn data_version(&self, resolved: &Resolved<'_>) -> Option<u32>

Source§

fn write( &self, resolved: &Resolved<'_>, data: &[u8], op: WriteOp, ctx: &InteractionContext<'_>, ) -> Result<(), Status>

Source§

fn invoke( &self, resolved: &ResolvedCommand<'_>, fields: Option<&[u8]>, ctx: &InteractionContext<'_>, w: &mut TlvWriter<'_>, tag: Tag, ) -> Result<Option<CommandId>, StatusIb>

Source§

impl<A: Cluster, B: Cluster, C: Cluster, D: Cluster, E: Cluster, F: Cluster, G: Cluster, H: Cluster, I: Cluster, J: Cluster, K: Cluster> ClusterHandler for (A, B, C, D, E, F, G, H, I, J, K)

Source§

fn on_lifecycle(&self, event: Lifecycle)

Broadcast, not routed: a fabric going away is a fact about the node, and every cluster in the tuple is downstream of it.

Source§

fn read( &self, resolved: &Resolved<'_>, ctx: &InteractionContext<'_>, w: &mut TlvWriter<'_>, tag: Tag, ) -> Result<(), Status>

Source§

fn data_version(&self, resolved: &Resolved<'_>) -> Option<u32>

Source§

fn write( &self, resolved: &Resolved<'_>, data: &[u8], op: WriteOp, ctx: &InteractionContext<'_>, ) -> Result<(), Status>

Source§

fn invoke( &self, resolved: &ResolvedCommand<'_>, fields: Option<&[u8]>, ctx: &InteractionContext<'_>, w: &mut TlvWriter<'_>, tag: Tag, ) -> Result<Option<CommandId>, StatusIb>

Source§

impl<A: Cluster, B: Cluster, C: Cluster, D: Cluster, E: Cluster, F: Cluster, G: Cluster, H: Cluster, I: Cluster, J: Cluster> ClusterHandler for (A, B, C, D, E, F, G, H, I, J)

Source§

fn on_lifecycle(&self, event: Lifecycle)

Broadcast, not routed: a fabric going away is a fact about the node, and every cluster in the tuple is downstream of it.

Source§

fn read( &self, resolved: &Resolved<'_>, ctx: &InteractionContext<'_>, w: &mut TlvWriter<'_>, tag: Tag, ) -> Result<(), Status>

Source§

fn data_version(&self, resolved: &Resolved<'_>) -> Option<u32>

Source§

fn write( &self, resolved: &Resolved<'_>, data: &[u8], op: WriteOp, ctx: &InteractionContext<'_>, ) -> Result<(), Status>

Source§

fn invoke( &self, resolved: &ResolvedCommand<'_>, fields: Option<&[u8]>, ctx: &InteractionContext<'_>, w: &mut TlvWriter<'_>, tag: Tag, ) -> Result<Option<CommandId>, StatusIb>

Source§

impl<A: Cluster, B: Cluster, C: Cluster, D: Cluster, E: Cluster, F: Cluster, G: Cluster, H: Cluster, I: Cluster> ClusterHandler for (A, B, C, D, E, F, G, H, I)

Source§

fn on_lifecycle(&self, event: Lifecycle)

Broadcast, not routed: a fabric going away is a fact about the node, and every cluster in the tuple is downstream of it.

Source§

fn read( &self, resolved: &Resolved<'_>, ctx: &InteractionContext<'_>, w: &mut TlvWriter<'_>, tag: Tag, ) -> Result<(), Status>

Source§

fn data_version(&self, resolved: &Resolved<'_>) -> Option<u32>

Source§

fn write( &self, resolved: &Resolved<'_>, data: &[u8], op: WriteOp, ctx: &InteractionContext<'_>, ) -> Result<(), Status>

Source§

fn invoke( &self, resolved: &ResolvedCommand<'_>, fields: Option<&[u8]>, ctx: &InteractionContext<'_>, w: &mut TlvWriter<'_>, tag: Tag, ) -> Result<Option<CommandId>, StatusIb>

Source§

impl<A: Cluster, B: Cluster, C: Cluster, D: Cluster, E: Cluster, F: Cluster, G: Cluster, H: Cluster> ClusterHandler for (A, B, C, D, E, F, G, H)

Source§

fn on_lifecycle(&self, event: Lifecycle)

Broadcast, not routed: a fabric going away is a fact about the node, and every cluster in the tuple is downstream of it.

Source§

fn read( &self, resolved: &Resolved<'_>, ctx: &InteractionContext<'_>, w: &mut TlvWriter<'_>, tag: Tag, ) -> Result<(), Status>

Source§

fn data_version(&self, resolved: &Resolved<'_>) -> Option<u32>

Source§

fn write( &self, resolved: &Resolved<'_>, data: &[u8], op: WriteOp, ctx: &InteractionContext<'_>, ) -> Result<(), Status>

Source§

fn invoke( &self, resolved: &ResolvedCommand<'_>, fields: Option<&[u8]>, ctx: &InteractionContext<'_>, w: &mut TlvWriter<'_>, tag: Tag, ) -> Result<Option<CommandId>, StatusIb>

Source§

impl<A: Cluster, B: Cluster, C: Cluster, D: Cluster, E: Cluster, F: Cluster, G: Cluster> ClusterHandler for (A, B, C, D, E, F, G)

Source§

fn on_lifecycle(&self, event: Lifecycle)

Broadcast, not routed: a fabric going away is a fact about the node, and every cluster in the tuple is downstream of it.

Source§

fn read( &self, resolved: &Resolved<'_>, ctx: &InteractionContext<'_>, w: &mut TlvWriter<'_>, tag: Tag, ) -> Result<(), Status>

Source§

fn data_version(&self, resolved: &Resolved<'_>) -> Option<u32>

Source§

fn write( &self, resolved: &Resolved<'_>, data: &[u8], op: WriteOp, ctx: &InteractionContext<'_>, ) -> Result<(), Status>

Source§

fn invoke( &self, resolved: &ResolvedCommand<'_>, fields: Option<&[u8]>, ctx: &InteractionContext<'_>, w: &mut TlvWriter<'_>, tag: Tag, ) -> Result<Option<CommandId>, StatusIb>

Source§

impl<A: Cluster, B: Cluster, C: Cluster, D: Cluster, E: Cluster, F: Cluster> ClusterHandler for (A, B, C, D, E, F)

Source§

fn on_lifecycle(&self, event: Lifecycle)

Broadcast, not routed: a fabric going away is a fact about the node, and every cluster in the tuple is downstream of it.

Source§

fn read( &self, resolved: &Resolved<'_>, ctx: &InteractionContext<'_>, w: &mut TlvWriter<'_>, tag: Tag, ) -> Result<(), Status>

Source§

fn data_version(&self, resolved: &Resolved<'_>) -> Option<u32>

Source§

fn write( &self, resolved: &Resolved<'_>, data: &[u8], op: WriteOp, ctx: &InteractionContext<'_>, ) -> Result<(), Status>

Source§

fn invoke( &self, resolved: &ResolvedCommand<'_>, fields: Option<&[u8]>, ctx: &InteractionContext<'_>, w: &mut TlvWriter<'_>, tag: Tag, ) -> Result<Option<CommandId>, StatusIb>

Source§

impl<A: Cluster, B: Cluster, C: Cluster, D: Cluster, E: Cluster> ClusterHandler for (A, B, C, D, E)

Source§

fn on_lifecycle(&self, event: Lifecycle)

Broadcast, not routed: a fabric going away is a fact about the node, and every cluster in the tuple is downstream of it.

Source§

fn read( &self, resolved: &Resolved<'_>, ctx: &InteractionContext<'_>, w: &mut TlvWriter<'_>, tag: Tag, ) -> Result<(), Status>

Source§

fn data_version(&self, resolved: &Resolved<'_>) -> Option<u32>

Source§

fn write( &self, resolved: &Resolved<'_>, data: &[u8], op: WriteOp, ctx: &InteractionContext<'_>, ) -> Result<(), Status>

Source§

fn invoke( &self, resolved: &ResolvedCommand<'_>, fields: Option<&[u8]>, ctx: &InteractionContext<'_>, w: &mut TlvWriter<'_>, tag: Tag, ) -> Result<Option<CommandId>, StatusIb>

Source§

impl<A: Cluster, B: Cluster, C: Cluster, D: Cluster> ClusterHandler for (A, B, C, D)

Source§

fn on_lifecycle(&self, event: Lifecycle)

Broadcast, not routed: a fabric going away is a fact about the node, and every cluster in the tuple is downstream of it.

Source§

fn read( &self, resolved: &Resolved<'_>, ctx: &InteractionContext<'_>, w: &mut TlvWriter<'_>, tag: Tag, ) -> Result<(), Status>

Source§

fn data_version(&self, resolved: &Resolved<'_>) -> Option<u32>

Source§

fn write( &self, resolved: &Resolved<'_>, data: &[u8], op: WriteOp, ctx: &InteractionContext<'_>, ) -> Result<(), Status>

Source§

fn invoke( &self, resolved: &ResolvedCommand<'_>, fields: Option<&[u8]>, ctx: &InteractionContext<'_>, w: &mut TlvWriter<'_>, tag: Tag, ) -> Result<Option<CommandId>, StatusIb>

Source§

impl<A: Cluster, B: Cluster, C: Cluster> ClusterHandler for (A, B, C)

Source§

fn on_lifecycle(&self, event: Lifecycle)

Broadcast, not routed: a fabric going away is a fact about the node, and every cluster in the tuple is downstream of it.

Source§

fn read( &self, resolved: &Resolved<'_>, ctx: &InteractionContext<'_>, w: &mut TlvWriter<'_>, tag: Tag, ) -> Result<(), Status>

Source§

fn data_version(&self, resolved: &Resolved<'_>) -> Option<u32>

Source§

fn write( &self, resolved: &Resolved<'_>, data: &[u8], op: WriteOp, ctx: &InteractionContext<'_>, ) -> Result<(), Status>

Source§

fn invoke( &self, resolved: &ResolvedCommand<'_>, fields: Option<&[u8]>, ctx: &InteractionContext<'_>, w: &mut TlvWriter<'_>, tag: Tag, ) -> Result<Option<CommandId>, StatusIb>

Source§

impl<A: Cluster, B: Cluster> ClusterHandler for (A, B)

Source§

fn on_lifecycle(&self, event: Lifecycle)

Broadcast, not routed: a fabric going away is a fact about the node, and every cluster in the tuple is downstream of it.

Source§

fn read( &self, resolved: &Resolved<'_>, ctx: &InteractionContext<'_>, w: &mut TlvWriter<'_>, tag: Tag, ) -> Result<(), Status>

Source§

fn data_version(&self, resolved: &Resolved<'_>) -> Option<u32>

Source§

fn write( &self, resolved: &Resolved<'_>, data: &[u8], op: WriteOp, ctx: &InteractionContext<'_>, ) -> Result<(), Status>

Source§

fn invoke( &self, resolved: &ResolvedCommand<'_>, fields: Option<&[u8]>, ctx: &InteractionContext<'_>, w: &mut TlvWriter<'_>, tag: Tag, ) -> Result<Option<CommandId>, StatusIb>

Source§

impl<A: Cluster> ClusterHandler for (A,)

Source§

fn on_lifecycle(&self, event: Lifecycle)

Broadcast, not routed: a fabric going away is a fact about the node, and every cluster in the tuple is downstream of it.

Source§

fn read( &self, resolved: &Resolved<'_>, ctx: &InteractionContext<'_>, w: &mut TlvWriter<'_>, tag: Tag, ) -> Result<(), Status>

Source§

fn data_version(&self, resolved: &Resolved<'_>) -> Option<u32>

Source§

fn write( &self, resolved: &Resolved<'_>, data: &[u8], op: WriteOp, ctx: &InteractionContext<'_>, ) -> Result<(), Status>

Source§

fn invoke( &self, resolved: &ResolvedCommand<'_>, fields: Option<&[u8]>, ctx: &InteractionContext<'_>, w: &mut TlvWriter<'_>, tag: Tag, ) -> Result<Option<CommandId>, StatusIb>

Source§

impl<T: ClusterHandler + ?Sized> ClusterHandler for &T

A shared reference to a handler is a handler.

Which is what lets a device assemble its cluster table out of borrowed clusters — the clusters themselves own references to the fabric table, the key store and the fail-safe, so they are rarely cheap to move and there is no reason to.

Source§

fn read( &self, resolved: &Resolved<'_>, ctx: &InteractionContext<'_>, w: &mut TlvWriter<'_>, tag: Tag, ) -> Result<(), Status>

Source§

fn data_version(&self, resolved: &Resolved<'_>) -> Option<u32>

Source§

fn write( &self, resolved: &Resolved<'_>, data: &[u8], op: WriteOp, ctx: &InteractionContext<'_>, ) -> Result<(), Status>

Source§

fn invoke( &self, resolved: &ResolvedCommand<'_>, fields: Option<&[u8]>, ctx: &InteractionContext<'_>, w: &mut TlvWriter<'_>, tag: Tag, ) -> Result<Option<CommandId>, StatusIb>

Source§

fn on_lifecycle(&self, event: Lifecycle)

Implementors§

Source§

impl ClusterHandler for AdministratorCommissioning<'_>

Available on crate feature rustcrypto only.
Source§

impl ClusterHandler for BasicInformation<'_>

Source§

impl ClusterHandler for BridgedDeviceBasicInformation<'_>

Source§

impl ClusterHandler for Descriptor<'_>

Source§

impl ClusterHandler for FixedLabel<'_>

Source§

impl ClusterHandler for GeneralCommissioning<'_>

Source§

impl ClusterHandler for PowerTopology<'_>

Source§

impl<A: ClusterHandler, B: ClusterHandler, C: ClusterHandler, D: ClusterHandler, E: ClusterHandler, F: ClusterHandler, G: ClusterHandler, H: ClusterHandler> ClusterHandler for Endpoints<(At<A>, At<B>, At<C>, At<D>, At<E>, At<F>, At<G>, At<H>)>

Source§

impl<A: ClusterHandler, B: ClusterHandler, C: ClusterHandler, D: ClusterHandler, E: ClusterHandler, F: ClusterHandler, G: ClusterHandler> ClusterHandler for Endpoints<(At<A>, At<B>, At<C>, At<D>, At<E>, At<F>, At<G>)>

Source§

impl<A: ClusterHandler, B: ClusterHandler, C: ClusterHandler, D: ClusterHandler, E: ClusterHandler, F: ClusterHandler> ClusterHandler for Endpoints<(At<A>, At<B>, At<C>, At<D>, At<E>, At<F>)>

Source§

impl<A: ClusterHandler, B: ClusterHandler, C: ClusterHandler, D: ClusterHandler, E: ClusterHandler> ClusterHandler for Endpoints<(At<A>, At<B>, At<C>, At<D>, At<E>)>

Source§

impl<A: ClusterHandler, B: ClusterHandler, C: ClusterHandler, D: ClusterHandler> ClusterHandler for Endpoints<(At<A>, At<B>, At<C>, At<D>)>

Source§

impl<A: ClusterHandler, B: ClusterHandler, C: ClusterHandler> ClusterHandler for Endpoints<(At<A>, At<B>, At<C>)>

Source§

impl<A: ClusterHandler, B: ClusterHandler> ClusterHandler for Endpoints<(At<A>, At<B>)>

Source§

impl<A: ClusterHandler> ClusterHandler for Endpoints<(At<A>,)>

Source§

impl<C: Config, K: KeyStore, R: Rng, const N: usize> ClusterHandler for OperationalCredentials<'_, C, K, R, N>

Available on crate feature rustcrypto only.
Source§

impl<C: Config, T: GroupTable, const K: usize, const M: usize> ClusterHandler for GroupKeyManagement<'_, C, T, K, M>

Available on crate feature rustcrypto only.
Source§

impl<C: Config, const M: usize, const E: usize, const K: usize, const G: usize> ClusterHandler for Groupcast<'_, C, M, E, K, G>

Available on crate features provisional and rustcrypto only.
Source§

impl<C: Config, const N: usize, A: StayActive> ClusterHandler for IcdManagement<'_, C, N, A>

Available on crate feature rustcrypto only.
Source§

impl<C: Config, const N: usize, const S: usize, const T: usize> ClusterHandler for AccessControl<'_, C, N, S, T>

Source§

impl<C: Config, const N: usize> ClusterHandler for Binding<C, N>

Source§

impl<D: Diagnostics> ClusterHandler for GeneralDiagnostics<'_, D>

Source§

impl<D: EthernetDriver> ClusterHandler for EthernetNetworkDiagnostics<'_, D>

Source§

impl<D: NetworkDriver, const N: usize> ClusterHandler for NetworkCommissioning<'_, D, N>

Source§

impl<D: ThreadDriver, const E: usize> ClusterHandler for ThreadNetworkDiagnostics<'_, D, E>

Source§

impl<D: WiFiDriver, const E: usize> ClusterHandler for WiFiNetworkDiagnostics<'_, D, E>

Source§

impl<H: CommissionerControlHooks, const N: usize> ClusterHandler for CommissionerControl<'_, H, N>

Source§

impl<H: DemHooks> ClusterHandler for DeviceEnergyManagement<'_, H>

Source§

impl<H: EnergyMeterHooks> ClusterHandler for ElectricalEnergyMeasurement<'_, H>

Source§

impl<H: EvseHooks, const T: usize> ClusterHandler for EnergyEvse<'_, H, T>

Source§

impl<H: IdentifyHooks> ClusterHandler for Identify<'_, H>

Source§

impl<H: JointFabricHooks> ClusterHandler for JointFabricAdministrator<'_, H>

Available on crate feature rustcrypto only.
Source§

impl<H: LevelControlHooks, O: OnOffState> ClusterHandler for LevelControl<'_, H, O>

Source§

impl<H: ModeHooks, const CLUSTER: ClusterId> ClusterHandler for Mode<'_, H, CLUSTER>

Source§

impl<H: OnOffHooks> ClusterHandler for OnOff<'_, H>

Source§

impl<H: OtaProviderHooks> ClusterHandler for OtaProvider<'_, H>

Source§

impl<H: OtaRequestorHooks, const N: usize> ClusterHandler for OtaRequestor<'_, H, N>

Source§

impl<H: PowerMeterHooks> ClusterHandler for ElectricalPowerMeasurement<'_, H>

Source§

impl<H: SceneHooks, G: GroupMembership, const N: usize, const EFS: usize, const F: usize> ClusterHandler for Scenes<'_, H, G, N, EFS, F>

Source§

impl<H: TlsCertificateHooks, const R: usize, const C: usize, const E: usize> ClusterHandler for CertificateManagement<'_, H, R, C, E>

Available on crate feature rustcrypto only.
Source§

impl<H: WaterHeaterHooks> ClusterHandler for WaterHeaterManagement<'_, H>

Source§

impl<M: SoftwareMetrics> ClusterHandler for SoftwareDiagnostics<'_, M>

Source§

impl<const N: usize, I: Identifying, S: ScenePurge> ClusterHandler for Groups<'_, N, I, S>

Source§

impl<const N: usize, const G: usize, const K: usize, const A: usize, const M: usize> ClusterHandler for JointFabricDatastore<'_, N, G, K, A, M>

Available on crate feature rustcrypto only.
Source§

impl<const N: usize> ClusterHandler for UserLabel<N>

Source§

impl<const R: usize, const C: usize, const E: usize> ClusterHandler for ClientManagement<'_, R, C, E>

Available on crate feature rustcrypto only.