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}>{ /* 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>
impl<'a, C, B, T, K, N, const NS: usize, const NE: usize> InteractionModel<'a, C, B, T, K, N, NoopWirelessNetCtl, NS, NE>
Sourcepub 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>
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 theMatterinstancebuffers- a reference to an implementation ofBuffers<IMBuffer>which is used for allocating RX and TX buffers on the fly, when necessaryhandler- an instance of typeTwhich implements theDataModeltrait. 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 thers_matter::dm::root_endpoint::with_methodskv- an instance of typeKwhich implements theKvBlobStoreAccesstrait (obtain one viaMatter::kv). This instance is used for interacting with the key-value blob store.state- a reference to theInteractionModelStateholding the subscriptions table, the events queue and the network store (the latter parameterized by theNetworksimplementationN).
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>
impl<'a, C, B, T, K, N, NC, const NS: usize, const NE: usize> InteractionModel<'a, C, B, T, K, N, NC, NS, NE>
Sourcepub 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>
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 theMatterinstancebuffers- a reference to an implementation ofBuffers<IMBuffer>which is used for allocating RX and TX buffers on the fly, when necessaryhandler- an instance of typeTwhich implements theDataModeltrait. 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 thers_matter::dm::root_endpoint::with_methodskv- an instance of typeKwhich implements theKvBlobStoreAccesstrait (obtain one viaMatter::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 fromInteractionModel::run.state- a reference to theInteractionModelStateholding the subscriptions table, the events queue and the network store (the latter parameterized by theNetworksimplementationN).
Sourcepub const fn matter(&self) -> &'a Matter<'a>
pub const fn matter(&self) -> &'a Matter<'a>
Get a reference to the Matter instance this data model is associated with.
pub const fn crypto(&self) -> &C
Sourcepub fn open_basic_comm_window(&self, timeout_secs: u16) -> Result<(), Error>
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).
Sourcepub fn close_comm_window(&self) -> Result<bool, Error>
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.
Sourcepub fn bump_configuration_version(&self) -> Result<u32, Error>
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.
Sourcepub async fn run(&self) -> Result<(), Error>
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).
Sourcepub async fn connect_once(&self, network_id: &[u8]) -> Result<(), Error>
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.
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>
impl<C, B, T, K, N, NC, const NS: usize, const NE: usize> AttrChangeNotifier for InteractionModel<'_, C, B, T, K, N, NC, NS, NE>
Source§fn notify_attr_changed(&self, endpoint_id: u16, cluster_id: u32, attr_id: u32)
fn notify_attr_changed(&self, endpoint_id: u16, cluster_id: u32, attr_id: u32)
Source§fn notify_cluster_changed(&self, endpoint_id: u16, cluster_id: u32)
fn notify_cluster_changed(&self, endpoint_id: u16, cluster_id: u32)
Source§fn notify_endpoint_changed(&self, endpoint_id: u16)
fn notify_endpoint_changed(&self, endpoint_id: u16)
Source§fn notify_all_changed(&self)
fn notify_all_changed(&self)
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>
impl<C, B, T, K, N, NC, const NS: usize, const NE: usize> EventEmitter for InteractionModel<'_, C, B, T, K, N, NC, NS, NE>
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>
impl<C, B, T, K, N, NC, const NS: usize, const NE: usize> ExchangeHandler for InteractionModel<'_, C, B, T, K, N, NC, NS, NE>
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>
impl<C, B, T, K, N, NC, const NS: usize, const NE: usize> HandlerContext for InteractionModel<'_, C, B, T, K, N, NC, NS, NE>
Source§fn crypto(&self) -> impl Crypto
fn crypto(&self) -> impl Crypto
Source§fn kv(&self) -> impl KvBlobStoreAccess
fn kv(&self) -> impl KvBlobStoreAccess
Source§fn networks(&self) -> impl NetworksAccess
fn networks(&self) -> impl NetworksAccess
Source§fn metadata(&self) -> impl Metadata
fn metadata(&self) -> impl Metadata
Source§fn handler(&self) -> impl AsyncHandler
fn handler(&self) -> impl AsyncHandler
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>
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> 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