pub trait HandlerContext: AttrChangeNotifier + EventEmitter {
// Required methods
fn matter(&self) -> &Matter<'_>;
fn crypto(&self) -> impl Crypto;
fn kv(&self) -> impl KvBlobStoreAccess;
fn networks(&self) -> impl NetworksAccess;
fn metadata(&self) -> impl Metadata;
fn handler(&self) -> impl AsyncHandler;
fn buffers(
&self,
) -> impl Buffers<Vec<u8, rs_matter::::transport::exchange::Buffer::{constant#0}>>;
fn im_stats(&self) -> impl ImStats;
fn notify_fabric_removed(&self, fab_idx: NonZero<u8>);
}Expand description
A context super-type that is also passed to the (Async)Handler::run method.
It provides access to the Matter instance and to Data Model-related objects, which could be useful in the context of executing background tasks specific for the concrete handler.
Required Methods§
Sourcefn crypto(&self) -> impl Crypto
fn crypto(&self) -> impl Crypto
Return the crypto object that is associated with this operation.
Sourcefn kv(&self) -> impl KvBlobStoreAccess
fn kv(&self) -> impl KvBlobStoreAccess
Return a blob store that can be used to persist data across reboots.
Sourcefn networks(&self) -> impl NetworksAccess
fn networks(&self) -> impl NetworksAccess
Return the networks access object.
Sourcefn metadata(&self) -> impl Metadata
fn metadata(&self) -> impl Metadata
Return the metadata of the node that is associated with this handler.
Sourcefn handler(&self) -> impl AsyncHandler
fn handler(&self) -> impl AsyncHandler
Return the global handler that this handler is part of.
Useful in case a concrete cluster handler (say, the Scenes one) needs to access the global handler so as to invoke read/write/invoke operations on other clusters.
Sourcefn buffers(
&self,
) -> impl Buffers<Vec<u8, rs_matter::::transport::exchange::Buffer::{constant#0}>>
fn buffers( &self, ) -> impl Buffers<Vec<u8, rs_matter::::transport::exchange::Buffer::{constant#0}>>
Return the buffer pool of the Data Model.
Useful in case e.g. a concrete cluster handler needs to invoke read/write/invoke operations on other clusters, and the TLV input/output data for those operations is non-trivial in size.
Sourcefn im_stats(&self) -> impl ImStats
fn im_stats(&self) -> impl ImStats
Return the Interaction Model statistics of the node.
Lets a handler read IM-internal figures it cannot otherwise reach - the
General Diagnostics handler uses it for DeviceLoadStatus.
Sourcefn notify_fabric_removed(&self, fab_idx: NonZero<u8>)
fn notify_fabric_removed(&self, fab_idx: NonZero<u8>)
Notify that the fabric with the given local index has been removed
from the fabric table, by synchronously broadcasting
LifecycleOp::FabricRemoval to every handler in the data model.
Two caveats for callers:
- The broadcast runs the handlers’
lifecyclemethods inline, so this must NOT be called while holding the Matter state lock (i.e. from within awith_stateclosure) - handlers are free to access the Matter instance themselves. - For the same reason, a handler must not call this from its own
lifecycleimplementation (infinite recursion).
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".