pub struct IdentifyHandler<H = ()> { /* private fields */ }Expand description
The handler for the Identify Matter cluster.
Per-endpoint instance: each endpoint that advertises the Identify
cluster must own a separate IdentifyHandler so countdown state and
attribute reports stay segregated. The endpoint ID is captured lazily
from the first write/command that lands on this instance — no
constructor argument required, and the same handler type can therefore
serve any endpoint without per-endpoint specialization.
State model: rather than physically decrement an IdentifyTime counter
at 1 Hz, the handler captures the originally-requested
(endpoint_id, duration, start_instant) when an Identify command (or
IdentifyTime write) arrives, and computes the remaining seconds
on-demand whenever the framework reads the attribute. This is
observably equivalent to a physical countdown per Matter App Cluster
spec (which constrains the attribute’s observable value, not
the implementation’s internal storage), but it avoids 60 wakeups for
a 60-second identify — the run task only schedules a
single Timer::at(deadline) per identify cycle, fires the final-zero
notify_attr_changed, and parks. On battery-powered targets that’s the
difference between a measurable wake-and-radio-on hit per second and a
non-event.
Concurrency: the session cell is wrapped in a blocking Mutex so the
handler is sound under a future work-stealing executor configuration of
rs-matter. Lock holds are bounded to a single Cell::get / Cell::set
each — the lock is never held across .await points.
Dataver is bumped automatically by the framework after each write/invoke
(via the cluster handler chain’s bump_dataver(MatchContext)), and
again whenever a notify_attr_changed is dispatched. This handler
therefore never calls self.dataver.changed() directly — it only
signals attribute-changed notifications, and the framework takes care
of dataver progression.
The handler implements the (sync) ClusterHandler trait — which keeps
the read/write/invoke surface as cheap sync calls (smaller footprint
than ClusterAsyncHandler’s all-async state machines) — and provides
the deadline-timer task via ClusterHandler::run. Adapt it to the
generic rs-matter Handler trait with IdentifyHandler::adapt.
Implementations§
Source§impl IdentifyHandler
impl IdentifyHandler
Sourcepub const fn new(dataver: Dataver) -> IdentifyHandler
pub const fn new(dataver: Dataver) -> IdentifyHandler
Creates a new IdentifyHandler with the no-hardware default
() hooks. Suitable for headless test fixtures.
The endpoint ID is not a constructor argument: it is captured at
the first write/command from the surrounding OperationContext.
Source§impl<H> IdentifyHandler<H>where
H: IdentifyHooks,
impl<H> IdentifyHandler<H>where
H: IdentifyHooks,
Sourcepub const fn new_with(dataver: Dataver, hooks: H) -> IdentifyHandler<H>
pub const fn new_with(dataver: Dataver, hooks: H) -> IdentifyHandler<H>
Creates a new IdentifyHandler with application-supplied hooks.
Sourcepub const fn adapt(self) -> HandlerAdaptor<IdentifyHandler<H>>
pub const fn adapt(self) -> HandlerAdaptor<IdentifyHandler<H>>
Adapt the handler instance to the generic rs-matter Handler trait.
Trait Implementations§
Source§impl<H> ClusterHandler for IdentifyHandler<H>where
H: IdentifyHooks,
impl<H> ClusterHandler for IdentifyHandler<H>where
H: IdentifyHooks,
fn dataver(&self) -> u32
fn dataver_changed(&self)
fn identify_time(&self, _ctx: impl ReadContext) -> Result<u16, Error>
fn identify_type( &self, _ctx: impl ReadContext, ) -> Result<IdentifyTypeEnum, Error>
fn set_identify_time( &self, ctx: impl WriteContext, value: u16, ) -> Result<(), Error>
fn handle_identify( &self, ctx: impl InvokeContext, request: IdentifyRequest<'_>, ) -> Result<(), Error>
fn handle_trigger_effect( &self, _ctx: impl InvokeContext, request: TriggerEffectRequest<'_>, ) -> Result<(), Error>
async fn run(&self, ctx: impl HandlerContext) -> Result<(), Error>
fn lifecycle( &self, _ctx: impl HandlerContext, _op: LifecycleOp, ) -> Result<(), Error>
Source§impl<H> IdentifyStatus for IdentifyHandler<H>where
H: IdentifyHooks,
impl<H> IdentifyStatus for IdentifyHandler<H>where
H: IdentifyHooks,
Source§fn is_identifying(&self) -> bool
fn is_identifying(&self) -> bool
IdentifyTime > 0).Auto Trait Implementations§
impl<H = ()> !Freeze for IdentifyHandler<H>
impl<H = ()> !RefUnwindSafe for IdentifyHandler<H>
impl<H = ()> !Sync for IdentifyHandler<H>
impl<H> Send for IdentifyHandler<H>where
H: Send,
impl<H> Unpin for IdentifyHandler<H>where
H: Unpin,
impl<H> UnsafeUnpin for IdentifyHandler<H>where
H: UnsafeUnpin,
impl<H> UnwindSafe for IdentifyHandler<H>where
H: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more