Skip to main content

Mode

Struct Mode 

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

Source

pub const WITH_START_UP_MODE: Optional<'static>

Everything §1.10.6 leaves to the product: StartUpMode.

Source

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.

Source

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.

Source

pub const fn spec(&self) -> &'static Cluster

The specification table this instance serves.

Source

pub fn current(&self) -> u8

CurrentMode (§1.10.6.2).

Source

pub const fn supported(&self) -> &'a [ModeOptionStruct<'a>]

SupportedModes (§1.10.6.1).

Source

pub fn start_up_mode(&self) -> Option<u8>

StartUpMode (§1.10.6.3), None for null.

Source

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.

Source

pub fn set_on_mode(&self, mode: Option<u8>) -> Result<(), Status>

Sets OnMode (§1.10.6.4) without a write interaction.

Source

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.

Source

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.

Source§

const ID: ClusterId = CLUSTER

The cluster id this implementation serves.
Source§

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>

Writes the value of resolved’s attribute under tag. Read more
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. Read more
Source§

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

Runs a command. Read more
Source§

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

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

fn on_lifecycle(&self, _event: Lifecycle)

Reacts to something that happened to the node (see Lifecycle). Read more
Source§

impl<'a, H: Debug + ModeHooks, const CLUSTER: ClusterId> Debug for Mode<'a, H, CLUSTER>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a, H, const CLUSTER: u32> !Freeze for Mode<'a, H, CLUSTER>

§

impl<'a, H, const CLUSTER: u32> !RefUnwindSafe for Mode<'a, H, CLUSTER>

§

impl<'a, H, const CLUSTER: u32> !Sync for Mode<'a, H, CLUSTER>

§

impl<'a, H, const CLUSTER: u32> Forget for Mode<'a, H, CLUSTER>

§

impl<'a, H, const CLUSTER: u32> Move for Mode<'a, H, CLUSTER>

§

impl<'a, H, const CLUSTER: u32> Send for Mode<'a, H, CLUSTER>
where &'a H: Send,

§

impl<'a, H, const CLUSTER: u32> Unpin for Mode<'a, H, CLUSTER>
where &'a H: Unpin,

§

impl<'a, H, const CLUSTER: u32> UnsafeUnpin for Mode<'a, H, CLUSTER>

§

impl<'a, H, const CLUSTER: u32> UnwindSafe for Mode<'a, H, CLUSTER>

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.