pub struct Mode<'a, H: ModeHooks, const CLUSTER: ClusterId> { /* private fields */ }Expand description
One cluster derived from Mode Base.
CLUSTER is the derived cluster’s id — a const parameter rather than a field, because
Cluster::ID is an associated constant and that is what lets a tuple of clusters
dispatch to this one. One implementation therefore serves fifteen distinct types, which
is exactly right: an endpoint with both an Energy EVSE Mode and a Water Heater Mode has two
clusters, not one cluster twice.
The SupportedModes list is borrowed rather than copied — §1.10.6.1 makes it F, fixed,
so it is the product’s const data.
Implementations§
Source§impl<'a, H: ModeHooks, const CLUSTER: ClusterId> Mode<'a, H, CLUSTER>
impl<'a, H: ModeHooks, const CLUSTER: ClusterId> Mode<'a, H, CLUSTER>
Sourcepub const WITH_START_UP_MODE: Optional<'static>
pub const WITH_START_UP_MODE: Optional<'static>
Everything §1.10.6 leaves to the product: StartUpMode.
Sourcepub fn new(
spec: &'static Cluster,
hooks: &'a H,
supported: &'a [ModeOptionStruct<'a>],
current: u8,
) -> Result<Self>
pub fn new( spec: &'static Cluster, hooks: &'a H, supported: &'a [ModeOptionStruct<'a>], current: u8, ) -> Result<Self>
A mode cluster over spec — one of the generated derived tables.
use matter_kit::clusters::generated::energy_evse_mode;
use matter_kit::clusters::mode::Mode;
let mode = Mode::<_, { energy_evse_mode::ID }>::new(
&energy_evse_mode::CLUSTER, &hooks, SUPPORTED, 0,
)?;Fails when spec is not the table for CLUSTER — the two are separate arguments and a
device that crossed them would answer one cluster’s paths with another’s elements — or
when supported breaks §1.10.6.1: fewer than two entries, a repeated Mode, a repeated
Label, or two entries whose mode-tag sets are equal. A controller shown two modes it
cannot tell apart has no way to know that it cannot.
Sourcepub fn conforming(
spec: &'static Cluster,
feature_map: u32,
optional: &Optional<'_>,
) -> Result<Conforming<4, 1, 1, 0>>
pub fn conforming( spec: &'static Cluster, feature_map: u32, optional: &Optional<'_>, ) -> Result<Conforming<4, 1, 1, 0>>
The descriptor for an instance, derived from the specification’s tables.
Sourcepub const fn supported(&self) -> &'a [ModeOptionStruct<'a>]
pub const fn supported(&self) -> &'a [ModeOptionStruct<'a>]
SupportedModes (§1.10.6.1).
Sourcepub fn start_up_mode(&self) -> Option<u8>
pub fn start_up_mode(&self) -> Option<u8>
StartUpMode (§1.10.6.3), None for null.
Sourcepub fn set_start_up_mode(&self, mode: Option<u8>) -> Result<(), Status>
pub fn set_start_up_mode(&self, mode: Option<u8>) -> Result<(), Status>
Sets StartUpMode without a write interaction.
Refuses a mode SupportedModes does not list, the same as a write does.
Sourcepub fn set_on_mode(&self, mode: Option<u8>) -> Result<(), Status>
pub fn set_on_mode(&self, mode: Option<u8>) -> Result<(), Status>
Sets OnMode (§1.10.6.4) without a write interaction.
Sourcepub fn start(&self, start_up_on_off_is_on: bool)
pub fn start(&self, start_up_on_off_is_on: bool)
§1.10.6.3’s start-up behaviour.
If this attribute is not null, the CurrentMode attribute SHALL be set to the StartUpMode value, when the server is powered up, except in the case when the OnMode attribute overrides the StartUpMode attribute.
start_up_on_off is On/Off’s StartUpOnOff where the endpoint has one: §1.10.6.4.1
makes OnMode win when the device is configured to come up on, because the endpoint
is then doing the thing OnMode describes.
Sourcepub fn on_off_changed(&self, was_on: bool, is_on: bool)
pub fn on_off_changed(&self, was_on: bool, is_on: bool)
§1.10.6.4’s table: the On/Off cluster on this endpoint changed.
Only OFF → ON moves the mode. A device that also acted on ON → ON would jump out of
whatever mode a user had just chosen every time an On command was re-sent, which for
a groupcast is every time anybody turns the room on.
Trait Implementations§
Source§impl<H: ModeHooks, const CLUSTER: ClusterId> Cluster for Mode<'_, H, CLUSTER>
So a tuple of clusters can dispatch to it by id — a different type per derived cluster.
impl<H: ModeHooks, const CLUSTER: ClusterId> Cluster for Mode<'_, H, CLUSTER>
So a tuple of clusters can dispatch to it by id — a different type per derived cluster.
Source§impl<H: ModeHooks, const CLUSTER: ClusterId> ClusterHandler for Mode<'_, H, CLUSTER>
impl<H: ModeHooks, const CLUSTER: ClusterId> ClusterHandler for Mode<'_, H, CLUSTER>
Source§fn read(
&self,
resolved: &Resolved<'_>,
_ctx: &InteractionContext<'_>,
w: &mut TlvWriter<'_>,
tag: Tag,
) -> Result<(), Status>
fn read( &self, resolved: &Resolved<'_>, _ctx: &InteractionContext<'_>, w: &mut TlvWriter<'_>, tag: Tag, ) -> Result<(), Status>
Source§fn write(
&self,
resolved: &Resolved<'_>,
data: &[u8],
_op: WriteOp,
_ctx: &InteractionContext<'_>,
) -> Result<(), Status>
fn write( &self, resolved: &Resolved<'_>, data: &[u8], _op: WriteOp, _ctx: &InteractionContext<'_>, ) -> Result<(), Status>
data — the encoded TLV element, tag included — into the attribute. Read more