Skip to main content

InteractionModel

Struct InteractionModel 

Source
pub struct InteractionModel<'a, C, B, T, K, N, NC = NoopWirelessNetCtl, const NS: usize = rs_matter::::im::InteractionModel::{constant#0}, const NE: usize = rs_matter::::im::InteractionModel::{constant#1}>
where B: Buffers<Vec<u8, rs_matter::::transport::exchange::Buffer::{constant#0}>>,
{ /* private fields */ }
Expand description

The implementation needs a DataModel instance to interact with the underlying clusters of the data model.

NC is the network controller type driving the (optional) wireless connection manager from InteractionModel::run. It defaults to NoopWirelessNetCtl, which is the right choice for Ethernet (and what the convenience InteractionModel::new constructor wires up); wireless devices pass a real controller via InteractionModel::new_with_net_ctl.

Implementations§

Source§

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

Source

pub fn new( matter: &'a Matter<'a>, crypto: C, buffers: &'a B, handler: T, kv: K, state: &'a InteractionModelState<N, NS, NE>, ) -> InteractionModel<'a, C, B, T, K, N, NoopWirelessNetCtl, NS, NE>

Create the data model for a device that does not need an operational wireless connection manager (typically an Ethernet device).

This is a convenience wrapper around InteractionModel::new_with_net_ctl that fixes the network controller to an inert NoopWirelessNetCtl, so InteractionModel::run’s connection-management branch stays dormant.

§Arguments
  • matter - a reference to the Matter instance
  • buffers - a reference to an implementation of Buffers<IMBuffer> which is used for allocating RX and TX buffers on the fly, when necessary
  • handler - an instance of type T which implements the DataModel trait. This instance is used for interacting with the underlying clusters of the data model. Note that the expectations is for the user to provide a handler that handles the Matter system clusters as well (Endpoint 0), possibly by decorating her own clusters with the rs_matter::dm::root_endpoint::with_ methods
  • kv - an instance of type K which implements the KvBlobStoreAccess trait (obtain one via Matter::kv). This instance is used for interacting with the key-value blob store.
  • state - a reference to the InteractionModelState holding the subscriptions table, the events queue and the network store (the latter parameterized by the Networks implementation N).
Source§

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

Source

pub fn new_with_net_ctl( matter: &'a Matter<'a>, crypto: C, buffers: &'a B, handler: T, kv: K, net_ctl: NC, state: &'a InteractionModelState<N, NS, NE>, ) -> InteractionModel<'a, C, B, T, K, N, NC, NS, NE>

Create the data model with an explicit network controller net_ctl.

Use this for wireless devices: net_ctl drives the operational connection manager run from InteractionModel::run (and is typically the same controller instance also wired into the NetworkCommissioning cluster handler). For Ethernet devices prefer the InteractionModel::new convenience constructor.

§Arguments
  • matter - a reference to the Matter instance
  • buffers - a reference to an implementation of Buffers<IMBuffer> which is used for allocating RX and TX buffers on the fly, when necessary
  • handler - an instance of type T which implements the DataModel trait. This instance is used for interacting with the underlying clusters of the data model. Note that the expectations is for the user to provide a handler that handles the Matter system clusters as well (Endpoint 0), possibly by decorating her own clusters with the rs_matter::dm::root_endpoint::with_ methods
  • kv - an instance of type K which implements the KvBlobStoreAccess trait (obtain one via Matter::kv). This instance is used for interacting with the key-value blob store.
  • net_ctl - the network controller (NetCtl + WirelessDiag + NetChangeNotif) used by the operational wireless connection manager driven from InteractionModel::run.
  • state - a reference to the InteractionModelState holding the subscriptions table, the events queue and the network store (the latter parameterized by the Networks implementation N).
Source

pub const fn matter(&self) -> &'a Matter<'a>

Get a reference to the Matter instance this data model is associated with.

Source

pub const fn crypto(&self) -> &C

Source

pub fn open_basic_comm_window(&self, timeout_secs: u16) -> Result<(), Error>

Open the basic commissioning window.

Equivalent to Matter::open_basic_comm_window but additionally bumps the data version of the AdministratorCommissioning cluster on the root endpoint and routes the change to subscribers — both happen automatically because this InteractionModel is itself the AttrChangeNotifier passed down.

Prefer this entry point over the Matter one for any code path that has a InteractionModel available; Matter::open_basic_comm_window is the building block we delegate to and does not bump dataver (see its docs).

Source

pub fn close_comm_window(&self) -> Result<bool, Error>

Close the active commissioning window.

Equivalent to Matter::close_comm_window but additionally bumps the AdministratorCommissioning dataver and routes subscribers via this InteractionModel’s AttrChangeNotifier. See open_basic_comm_window for the rationale.

Source

pub fn bump_configuration_version(&self) -> Result<u32, Error>

Bump BasicInformation::ConfigurationVersion by one, persist the new value, and notify subscribers (which also bumps the BasicInformation cluster’s dataver via this InteractionModel’s AttrChangeNotifier).

Per Matter Core Spec, callers MUST invoke this whenever the node’s exposed fixed-quality surface changes — typically after a firmware update that adds or removes functionality, after an internal reconfiguration that changes any F-quality attribute (Descriptor::ServerList, PartsList, …), or (for bridges) after a bridged node is added or removed. It is not invoked automatically by rs-matter because the library has no way to know about an application’s reconfiguration events.

Returns the new ConfigurationVersion value.

Source

pub async fn run(&self) -> Result<(), Error>

Run the Data Model instance.

This drives the IM timeout checks, the data-model handler’s own background job, the subscriptions reporting loop, and - for wireless devices - the operational connection manager (inert for Ethernet, where net_ctl is a NoopWirelessNetCtl).

Source

pub async fn connect_once(&self, network_id: &[u8]) -> Result<(), Error>

Perform a single, one-shot connect to the wireless network with the given ID, immediately and regardless of the commissioning status.

This drives the same WirelessMgr used by InteractionModel::run (over this model’s network controller and the network store owned by its InteractionModelState), but calls WirelessMgr::connect_once rather than the operational loop. It exists so a stack performing non-concurrent (BLE-only) commissioning can replay the deferred ConnectNetwork once the operational radio is up but before commissioning completes - without having to own a WirelessMgr (or the networks) itself.

Source

pub async fn handle(&self, exchange: &mut Exchange<'_>) -> Result<(), Error>

Answer a responding exchange using the DataModel instance wrapped by this exchange handler.

Trait Implementations§

Source§

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

Source§

fn notify_attr_changed(&self, endpoint_id: u16, cluster_id: u32, attr_id: u32)

Notify that the state of an attribute has changed. Read more
Source§

fn notify_cluster_changed(&self, endpoint_id: u16, cluster_id: u32)

Notify that every attribute of the given cluster may have changed. Read more
Source§

fn notify_endpoint_changed(&self, endpoint_id: u16)

Notify that every attribute on every cluster of the given endpoint may have changed. Read more
Source§

fn notify_all_changed(&self)

Notify that every attribute on every cluster on every endpoint may have changed. Read more
Source§

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

Source§

fn emit_event<F>( &self, endpoint_id: u16, cluster_id: u32, event_id: u32, priority: EventPriority, f: F, ) -> Result<u64, Error>
where F: FnOnce(EventTLVWrite<'_>) -> Result<(), Error>,

Emit an event. Read more
Source§

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

Source§

async fn handle(&self, exchange: Exchange<'_>) -> Result<(), Error>

Source§

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

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. Read more
Source§

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

Return the buffer pool of the Data Model. Read more

Auto Trait Implementations§

§

impl<'a, C, B, T, K, N, NC = NoopWirelessNetCtl, const NS: usize = rs_matter::::im::InteractionModel::{constant#0}, const NE: usize = rs_matter::::im::InteractionModel::{constant#1}> !Freeze for InteractionModel<'a, C, B, T, K, N, NC, NS, NE>

§

impl<'a, C, B, T, K, N, NC = NoopWirelessNetCtl, const NS: usize = rs_matter::::im::InteractionModel::{constant#0}, const NE: usize = rs_matter::::im::InteractionModel::{constant#1}> !RefUnwindSafe for InteractionModel<'a, C, B, T, K, N, NC, NS, NE>

§

impl<'a, C, B, T, K, N, NC = NoopWirelessNetCtl, const NS: usize = rs_matter::::im::InteractionModel::{constant#0}, const NE: usize = rs_matter::::im::InteractionModel::{constant#1}> !Send for InteractionModel<'a, C, B, T, K, N, NC, NS, NE>

§

impl<'a, C, B, T, K, N, NC = NoopWirelessNetCtl, const NS: usize = rs_matter::::im::InteractionModel::{constant#0}, const NE: usize = rs_matter::::im::InteractionModel::{constant#1}> !Sync for InteractionModel<'a, C, B, T, K, N, NC, NS, NE>

§

impl<'a, C, B, T, K, N, NC = NoopWirelessNetCtl, const NS: usize = rs_matter::::im::InteractionModel::{constant#0}, const NE: usize = rs_matter::::im::InteractionModel::{constant#1}> !UnwindSafe for InteractionModel<'a, C, B, T, K, N, NC, NS, NE>

§

impl<'a, C, B, T, K, N, NC, const NS: usize, const NE: usize> Unpin for InteractionModel<'a, C, B, T, K, N, NC, NS, NE>
where C: Unpin, K: Unpin, NC: Unpin, T: Unpin, <B as Buffers<Vec<u8, 1583>>>::Buffer<'a>: Unpin,

§

impl<'a, C, B, T, K, N, NC, const NS: usize, const NE: usize> UnsafeUnpin for InteractionModel<'a, C, B, T, K, N, NC, NS, NE>
where C: UnsafeUnpin, K: UnsafeUnpin, NC: UnsafeUnpin, T: UnsafeUnpin, <B as Buffers<Vec<u8, 1583>>>::Buffer<'a>: UnsafeUnpin,

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, E> Init<T, E> for T

Source§

unsafe fn __init(self, slot: *mut T) -> Result<(), E>

Initializes slot. Read more
Source§

fn chain<F>(self, f: F) -> ChainInit<Self, F, T, E>
where F: FnOnce(&mut T) -> Result<(), E>,

First initializes the value using self then calls the function f with the initialized value. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

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

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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

impl<T, I> IntoFallibleInit<T> for I
where I: Init<T>,

Source§

fn into_fallible<E>(self) -> impl Init<T, E>

Convert the infallible initializer to a fallible one.
Source§

impl<Source, Target> OctetsInto<Target> for Source
where Target: OctetsFrom<Source>,

Source§

type Error = <Target as OctetsFrom<Source>>::Error

Source§

fn try_octets_into( self, ) -> Result<Target, <Source as OctetsInto<Target>>::Error>

Performs the conversion.
Source§

fn octets_into(self) -> Target
where Self::Error: Into<Infallible>,

Performs an infallible conversion.
Source§

impl<T, E> PinInit<T, E> for T

Source§

unsafe fn __pinned_init(self, slot: *mut T) -> Result<(), E>

Initializes slot. Read more
Source§

fn pin_chain<F>(self, f: F) -> ChainPinInit<Self, F, T, E>
where F: FnOnce(Pin<&mut T>) -> Result<(), E>,

First initializes the value using self then calls the function f with the initialized value. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V