Skip to main content

HandlerContext

Trait HandlerContext 

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

Source

fn matter(&self) -> &Matter<'_>

Return the Matter object that is associated with this handler

Source

fn crypto(&self) -> impl Crypto

Return the crypto object that is associated with this operation.

Source

fn kv(&self) -> impl KvBlobStoreAccess

Return a blob store that can be used to persist data across reboots.

Source

fn networks(&self) -> impl NetworksAccess

Return the networks access object.

Source

fn metadata(&self) -> impl Metadata

Return the metadata of the node that is associated with this handler.

Source

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.

Source

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.

Source

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.

Source

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’ lifecycle methods inline, so this must NOT be called while holding the Matter state lock (i.e. from within a with_state closure) - handlers are free to access the Matter instance themselves.
  • For the same reason, a handler must not call this from its own lifecycle implementation (infinite recursion).

Dyn Compatibility§

This trait is not dyn compatible.

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

Implementations on Foreign Types§

Source§

impl<T> HandlerContext for &T
where T: HandlerContext,

Source§

fn matter(&self) -> &Matter<'_>

Source§

fn crypto(&self) -> impl Crypto

Source§

fn kv(&self) -> impl KvBlobStoreAccess

Source§

fn networks(&self) -> impl NetworksAccess

Source§

fn metadata(&self) -> impl Metadata

Source§

fn handler(&self) -> impl AsyncHandler

Source§

fn buffers( &self, ) -> impl Buffers<Vec<u8, rs_matter::::transport::exchange::Buffer::{constant#0}>>

Source§

fn im_stats(&self) -> impl ImStats

Source§

fn notify_fabric_removed(&self, fab_idx: NonZero<u8>)

Implementors§

Source§

impl<C, B, T, K, N, NC, R, const NS: usize, const NE: usize> HandlerContext for InteractionModel<'_, C, B, T, K, N, NC, R, NS, NE>
where C: Crypto, B: Buffers<Vec<u8, rs_matter::::transport::exchange::Buffer::{constant#0}>>, T: DataModel, K: KvBlobStoreAccess, N: Networks,