pub struct MatterStack<'a, const B: usize, N>where
N: Network,{ /* private fields */ }Expand description
The MatterStack struct is the main entry point for the Matter stack.
It wraps the actual rs-matter Matter instance and provides a simplified API for running the stack.
Implementations§
Source§impl<const B: usize, E> MatterStack<'_, B, Eth<E>>where
E: Embedding,
A specialization of the MatterStack for Ethernet.
impl<const B: usize, E> MatterStack<'_, B, Eth<E>>where
E: Embedding,
A specialization of the MatterStack for Ethernet.
Sourcepub const fn root_endpoint() -> Endpoint<'static>
pub const fn root_endpoint() -> Endpoint<'static>
Return a metadata for the root (Endpoint 0) of the Matter Node configured for Ethernet network.
Sourcepub async fn reset<C, H, S>(
&mut self,
crypto: C,
handler: H,
store: S,
) -> Result<(), Error>
pub async fn reset<C, H, S>( &mut self, crypto: C, handler: H, store: S, ) -> Result<(), Error>
Reset the Matter instance to the factory defaults by removing all fabrics and basic info settings
handler is the same data model handler that is passed to run: the
Interaction Model broadcasts a FactoryReset lifecycle op to it, so
cluster handlers owning persisted state of their own can drop it too.
Sourcepub async fn startup<C, S>(&mut self, crypto: C, store: S) -> Result<(), Error>where
C: Crypto,
S: KvBlobStore,
pub async fn startup<C, S>(&mut self, crypto: C, store: S) -> Result<(), Error>where
C: Crypto,
S: KvBlobStore,
Run the startup sequence of the stack: re-hydrate the persisted state and open the basic commissioning window if the device is not commissioned yet.
This is the Matter-level half of the startup (fabrics, basic info, RTC,
sessions). The Interaction Model half - the events watermark, the networks
store and the persisted subscriptions - is re-hydrated by run, because
InteractionModel::startup has to run on the very Interaction Model
instance that is then run: a resumed subscription borrows that instance’s
IM buffers, and constructing an InteractionModel clears the
subscriptions table.
Sourcepub fn run_preex<'t, U, N, M, C, H, K, X>(
&'t self,
net_stack: U,
netif: N,
mdns: M,
crypto: C,
handler: H,
kv: K,
user: X,
) -> impl Future<Output = Result<(), Error>> + 'twhere
U: NetStack + 't,
N: NetifDiag + NetChangeNotif + 't,
M: Mdns + 't,
C: Crypto + 't,
H: DataModel + 't,
K: KvBlobStoreAccess + 't,
X: UserTask + 't,
pub fn run_preex<'t, U, N, M, C, H, K, X>(
&'t self,
net_stack: U,
netif: N,
mdns: M,
crypto: C,
handler: H,
kv: K,
user: X,
) -> impl Future<Output = Result<(), Error>> + 'twhere
U: NetStack + 't,
N: NetifDiag + NetChangeNotif + 't,
M: Mdns + 't,
C: Crypto + 't,
H: DataModel + 't,
K: KvBlobStoreAccess + 't,
X: UserTask + 't,
Run the Matter stack for a pre-existing Ethernet network.
§Arguments
net_stack- a user-provided network stack implementationnetif- a user-providedNetifimplementation for the Ethernet networkmdns- a user-provided mDNS implementationcrypto- a user-provided crypto implementationhandler- a user-provided DM handler implementationkv- a user-providedKvBlobStoreAccessimplementation for loading the persisted state of the stackuser- a user-provided future that will be polled only when the netif interface is up
Sourcepub async fn run<N, C, H, K, X>(
&self,
ethernet: N,
crypto: C,
handler: H,
kv: K,
user: X,
) -> Result<(), Error>
pub async fn run<N, C, H, K, X>( &self, ethernet: N, crypto: C, handler: H, kv: K, user: X, ) -> Result<(), Error>
Run the Matter stack for an Ethernet network.
§Arguments
ethernet- a user-providedEthernetimplementationcrypto- a user-provided crypto implementationhandler- a user-provided DM handler implementationkv- a user-providedKvBlobStoreAccessimplementation for loading the persisted state of the stackuser- a user-provided future that will be polled only when the netif interface is up
Source§impl<const B: usize, E> MatterStack<'_, B, WirelessBle<Thread, E>>where
E: Embedding,
impl<const B: usize, E> MatterStack<'_, B, WirelessBle<Thread, E>>where
E: Embedding,
Sourcepub fn run_preex<'t, U, N, Q, D, G, C, H, K, X>(
&'t self,
net_stack: U,
netif: N,
net_ctl: Q,
mdns: D,
gatt: G,
crypto: C,
handler: H,
kv: K,
user: X,
) -> impl Future<Output = Result<(), Error>> + 'twhere
U: NetStack + 't,
N: NetifDiag + NetChangeNotif + 't,
Q: NetCtl + ThreadDiag + NetChangeNotif + 't,
D: Mdns + 't,
G: GattPeripheral + 't,
C: Crypto + 't,
H: DataModel + 't,
K: KvBlobStoreAccess + 't,
X: UserTask + 't,
pub fn run_preex<'t, U, N, Q, D, G, C, H, K, X>(
&'t self,
net_stack: U,
netif: N,
net_ctl: Q,
mdns: D,
gatt: G,
crypto: C,
handler: H,
kv: K,
user: X,
) -> impl Future<Output = Result<(), Error>> + 'twhere
U: NetStack + 't,
N: NetifDiag + NetChangeNotif + 't,
Q: NetCtl + ThreadDiag + NetChangeNotif + 't,
D: Mdns + 't,
G: GattPeripheral + 't,
C: Crypto + 't,
H: DataModel + 't,
K: KvBlobStoreAccess + 't,
X: UserTask + 't,
Run the Matter stack for an already pre-established wireless network where the BLE and the Thread stacks can co-exist.
§Arguments
net_stack- a user-providedNetStackimplementationnetif- a user-providedNetifimplementationcontroller- a user-providedControllerimplementationmdns- a user-providedMdnsimplementationgatt- a user-providedGattPeripheralimplementationcrypto- a user-providedCryptoimplementationhandler- a user-provided DM handler implementationkv- a user-providedKvBlobStoreAccessimplementationuser- a user-provided future that will be polled only when the netif interface is up
Sourcepub async fn run_coex<W, C, H, K, U>(
&self,
thread: W,
crypto: C,
handler: H,
kv: K,
user: U,
) -> Result<(), Error>
pub async fn run_coex<W, C, H, K, U>( &self, thread: W, crypto: C, handler: H, kv: K, user: U, ) -> Result<(), Error>
Run the Matter stack for a wireless network where the BLE and the Wifi stacks can co-exist.
§Arguments
thread- a user-providedThreadCoeximplementationcrypto- a user-providedCryptoimplementationhandler- a user-provided DM handler implementationkv- a user-providedKvBlobStoreAccessimplementationuser- a user-provided future that will be polled only when the netif interface is up
Sourcepub async fn run<W, C, H, K, U>(
&self,
thread: W,
crypto: C,
handler: H,
kv: K,
user: U,
) -> Result<(), Error>
pub async fn run<W, C, H, K, U>( &self, thread: W, crypto: C, handler: H, kv: K, user: U, ) -> Result<(), Error>
Run the Matter stack for a wireless network where the BLE and the Thread stacks cannot co-exist.
§Arguments
thread- a user-providedThread+Gattimplementationcrypto- a user-providedCryptoimplementationhandler- a user-provided DM handler implementationkv- a user-providedKvBlobStoreAccessimplementationuser- a user-provided future that will be polled only when the netif interface is up
Sourcepub const fn root_endpoint() -> Endpoint<'static>
pub const fn root_endpoint() -> Endpoint<'static>
Return a metadata for the root (Endpoint 0) of the Matter Node configured for BLE+Thread network.
Source§impl<const B: usize, E> MatterStack<'_, B, WirelessBle<Wifi, E>>where
E: Embedding,
impl<const B: usize, E> MatterStack<'_, B, WirelessBle<Wifi, E>>where
E: Embedding,
Sourcepub async fn run_preex<'t, U, N, Q, D, G, C, H, K, X>(
&'t self,
net_stack: U,
netif: N,
net_ctl: Q,
mdns: D,
gatt: G,
crypto: C,
handler: H,
kv: K,
user: X,
) -> impl Future<Output = Result<(), Error>> + 'twhere
U: NetStack + 't,
N: NetifDiag + NetChangeNotif + 't,
Q: NetCtl + WifiDiag + NetChangeNotif + 't,
D: Mdns + 't,
G: GattPeripheral + 't,
C: Crypto + 't,
H: DataModel + 't,
K: KvBlobStoreAccess + 't,
X: UserTask + 't,
pub async fn run_preex<'t, U, N, Q, D, G, C, H, K, X>(
&'t self,
net_stack: U,
netif: N,
net_ctl: Q,
mdns: D,
gatt: G,
crypto: C,
handler: H,
kv: K,
user: X,
) -> impl Future<Output = Result<(), Error>> + 'twhere
U: NetStack + 't,
N: NetifDiag + NetChangeNotif + 't,
Q: NetCtl + WifiDiag + NetChangeNotif + 't,
D: Mdns + 't,
G: GattPeripheral + 't,
C: Crypto + 't,
H: DataModel + 't,
K: KvBlobStoreAccess + 't,
X: UserTask + 't,
Run the Matter stack for an already pre-established wireless network where the BLE and the Wifi stacks can co-exist.
§Arguments
net_stack- a user-providedNetStackimplementationnetif- a user-providedNetifimplementationcontroller- a user-providedControllerimplementationmdns- a user-providedMdnsimplementationgatt- a user-providedGattPeripheralimplementationcrypto- a user-providedCryptoimplementationhandler- a user-provided DM handler implementationkv- a user-providedKvBlobStoreAccessimplementationuser- a user-provided future that will be polled only when the netif interface is up
Sourcepub async fn run_coex<W, C, H, K, U>(
&self,
wifi: W,
crypto: C,
handler: H,
kv: K,
user: U,
) -> Result<(), Error>
pub async fn run_coex<W, C, H, K, U>( &self, wifi: W, crypto: C, handler: H, kv: K, user: U, ) -> Result<(), Error>
Run the Matter stack for a wireless network where the BLE and the Wifi stacks can co-exist.
§Arguments
wifi- a user-providedWifiCoeximplementationcrypto- a user-providedCryptoimplementationhandler- a user-provided DM handler implementationkv- a user-providedKvBlobStoreAccessimplementationuser- a user-provided future that will be polled only when the netif interface is up
Sourcepub async fn run<W, C, H, K, U>(
&self,
wifi: W,
crypto: C,
handler: H,
kv: K,
user: U,
) -> Result<(), Error>
pub async fn run<W, C, H, K, U>( &self, wifi: W, crypto: C, handler: H, kv: K, user: U, ) -> Result<(), Error>
Run the Matter stack for a wireless network where the BLE and the Wifi stacks cannot co-exist.
§Arguments
wifi- a user-providedWifi+Gattimplementationcrypto- a user-providedCryptoimplementationhandler- a user-provided DM handler implementationkv- a user-providedKvBlobStoreAccessimplementationuser- a user-provided future that will be polled only when the netif interface is up
Sourcepub const fn root_endpoint() -> Endpoint<'static>
pub const fn root_endpoint() -> Endpoint<'static>
Return a metadata for the root (Endpoint 0) of the Matter Node configured for BLE+Wifi network.
Source§impl<const B: usize, T, E> MatterStack<'_, B, WirelessBle<T, E>>where
T: WirelessNetwork,
E: Embedding,
impl<const B: usize, T, E> MatterStack<'_, B, WirelessBle<T, E>>where
T: WirelessNetwork,
E: Embedding,
Sourcepub async fn reset<C, H, S>(
&mut self,
crypto: C,
handler: H,
store: S,
) -> Result<(), Error>
pub async fn reset<C, H, S>( &mut self, crypto: C, handler: H, store: S, ) -> Result<(), Error>
Reset the Matter instance to the factory defaults by removing all fabrics and basic info settings
handler is the same data model handler that is passed to run: the
Interaction Model broadcasts a FactoryReset lifecycle op to it, so
cluster handlers owning persisted state of their own can drop it too.
Sourcepub async fn startup<C, S>(&mut self, crypto: C, store: S) -> Result<(), Error>where
C: Crypto,
S: KvBlobStore,
pub async fn startup<C, S>(&mut self, crypto: C, store: S) -> Result<(), Error>where
C: Crypto,
S: KvBlobStore,
Run the startup sequence of the stack: re-hydrate the persisted state and open the basic communication window if the device is not commissioned yet.
This is the Matter-level half of the startup (fabrics, basic info, RTC,
sessions). The Interaction Model half - the events watermark, the networks
store and the persisted subscriptions - is re-hydrated by run, because
InteractionModel::startup has to run on the very Interaction Model
instance that is then run: a resumed subscription borrows that instance’s
IM buffers, and constructing an InteractionModel clears the
subscriptions table.
Source§impl<'a, const B: usize, N> MatterStack<'a, B, N>where
N: Network,
impl<'a, const B: usize, N> MatterStack<'a, B, N>where
N: Network,
Sourcepub const fn new(
dev_det: &'a BasicInfoConfig<'_>,
dev_comm: BasicCommData,
dev_att: &'a dyn DeviceAttestation,
) -> Self
pub const fn new( dev_det: &'a BasicInfoConfig<'_>, dev_comm: BasicCommData, dev_att: &'a dyn DeviceAttestation, ) -> Self
Create a new MatterStack instance.
pub fn init( dev_det: &'a BasicInfoConfig<'_>, dev_comm: BasicCommData, dev_att: &'a dyn DeviceAttestation, ) -> impl Init<Self>
Sourcepub fn replace_dev_att(&mut self, dev_att: &'a dyn DeviceAttestation)
pub fn replace_dev_att(&mut self, dev_att: &'a dyn DeviceAttestation)
A utility method to replace the initial Device Attestation Data Fetcher with another one.
Reasoning and use-cases explained in the documentation of replace_mdns.
Sourcepub const fn network(&self) -> &N
pub const fn network(&self) -> &N
Get a reference to the Network instance.
Useful when the user instantiates MatterStack with a custom network type.
Sourcepub fn kv<'s, S: KvBlobStore + 's>(
&'s self,
store: S,
) -> impl KvBlobStoreAccess + 's
pub fn kv<'s, S: KvBlobStore + 's>( &'s self, store: S, ) -> impl KvBlobStoreAccess + 's
Create a new shared KvBlobStore instance, which is used to read and write blobs from the storage.
The user needs to provide a KvBlobStore implementation, which is used to actually read and write the blobs from the storage.
§Arguments
store- the rawKvBlobStoreimplementation to wrap
Sourcepub fn open_basic_comm_window<C>(
&self,
crypto: C,
notify: &dyn AttrChangeNotifier,
) -> Result<(), Error>where
C: Crypto,
pub fn open_basic_comm_window<C>(
&self,
crypto: C,
notify: &dyn AttrChangeNotifier,
) -> Result<(), Error>where
C: Crypto,
Open the basic communication window, which allows commissioning tools to discover and commission the device.
§Arguments
crypto- a user-provided crypto implementation, necessary for the secure sessions establishment that happens in the basic communication windownotify- a user-providedAttrChangeNotifier; typically,Data Model::change_notify; used to notify the Matter instance about changes in the state of the clusters’ attributes, so that it can notify commissioning tools about them
Auto Trait Implementations§
impl<'a, const B: usize, N> !Freeze for MatterStack<'a, B, N>
impl<'a, const B: usize, N> !RefUnwindSafe for MatterStack<'a, B, N>
impl<'a, const B: usize, N> !Send for MatterStack<'a, B, N>
impl<'a, const B: usize, N> !Sync for MatterStack<'a, B, N>
impl<'a, const B: usize, N> !UnwindSafe for MatterStack<'a, B, N>
impl<'a, const B: usize, N> Unpin for MatterStack<'a, B, N>
impl<'a, const B: usize, N> UnsafeUnpin for MatterStack<'a, B, N>
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