Skip to main content

MatterStack

Struct MatterStack 

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

Source

pub const fn root_endpoint() -> Endpoint<'static>

Return a metadata for the root (Endpoint 0) of the Matter Node configured for Ethernet network.

Source

pub async fn reset<C, H, S>( &mut self, crypto: C, handler: H, store: S, ) -> Result<(), Error>
where C: Crypto, H: DataModel, S: KvBlobStore,

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.

Source

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.

Source

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>> + 't
where 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 implementation
  • netif - a user-provided Netif implementation for the Ethernet network
  • mdns - a user-provided mDNS implementation
  • crypto - a user-provided crypto implementation
  • handler - a user-provided DM handler implementation
  • kv - a user-provided KvBlobStoreAccess implementation for loading the persisted state of the stack
  • user - a user-provided future that will be polled only when the netif interface is up
Source

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-provided Ethernet implementation
  • crypto - a user-provided crypto implementation
  • handler - a user-provided DM handler implementation
  • kv - a user-provided KvBlobStoreAccess implementation for loading the persisted state of the stack
  • user - 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,

Source

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>> + 't
where 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-provided NetStack implementation
  • netif - a user-provided Netif implementation
  • controller - a user-provided Controller implementation
  • mdns - a user-provided Mdns implementation
  • gatt - a user-provided GattPeripheral implementation
  • crypto - a user-provided Crypto implementation
  • handler - a user-provided DM handler implementation
  • kv - a user-provided KvBlobStoreAccess implementation
  • user - a user-provided future that will be polled only when the netif interface is up
Source

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-provided ThreadCoex implementation
  • crypto - a user-provided Crypto implementation
  • handler - a user-provided DM handler implementation
  • kv - a user-provided KvBlobStoreAccess implementation
  • user - a user-provided future that will be polled only when the netif interface is up
Source

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-provided Thread + Gatt implementation
  • crypto - a user-provided Crypto implementation
  • handler - a user-provided DM handler implementation
  • kv - a user-provided KvBlobStoreAccess implementation
  • user - a user-provided future that will be polled only when the netif interface is up
Source

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,

Source

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>> + 't
where 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-provided NetStack implementation
  • netif - a user-provided Netif implementation
  • controller - a user-provided Controller implementation
  • mdns - a user-provided Mdns implementation
  • gatt - a user-provided GattPeripheral implementation
  • crypto - a user-provided Crypto implementation
  • handler - a user-provided DM handler implementation
  • kv - a user-provided KvBlobStoreAccess implementation
  • user - a user-provided future that will be polled only when the netif interface is up
Source

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-provided WifiCoex implementation
  • crypto - a user-provided Crypto implementation
  • handler - a user-provided DM handler implementation
  • kv - a user-provided KvBlobStoreAccess implementation
  • user - a user-provided future that will be polled only when the netif interface is up
Source

pub async fn run<W, C, H, K, U>( &self, wifi: W, crypto: C, handler: H, kv: K, user: U, ) -> Result<(), Error>
where W: Wifi + Gatt, C: Crypto, H: DataModel, K: KvBlobStoreAccess, U: UserTask,

Run the Matter stack for a wireless network where the BLE and the Wifi stacks cannot co-exist.

§Arguments
  • wifi - a user-provided Wifi + Gatt implementation
  • crypto - a user-provided Crypto implementation
  • handler - a user-provided DM handler implementation
  • kv - a user-provided KvBlobStoreAccess implementation
  • user - a user-provided future that will be polled only when the netif interface is up
Source

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

Source

pub async fn reset<C, H, S>( &mut self, crypto: C, handler: H, store: S, ) -> Result<(), Error>
where C: Crypto, H: DataModel, S: KvBlobStore,

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.

Source

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,

Source

pub const fn new( dev_det: &'a BasicInfoConfig<'_>, dev_comm: BasicCommData, dev_att: &'a dyn DeviceAttestation, ) -> Self

Create a new MatterStack instance.

Source

pub fn init( dev_det: &'a BasicInfoConfig<'_>, dev_comm: BasicCommData, dev_att: &'a dyn DeviceAttestation, ) -> impl Init<Self>

Source

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.

Source

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

Get a reference to the Matter instance.

Source

pub const fn network(&self) -> &N

Get a reference to the Network instance. Useful when the user instantiates MatterStack with a custom network type.

Source

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
Source

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 window
  • notify - a user-provided AttrChangeNotifier; 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>
where N: Unpin, <N as Network>::Networks: Unpin,

§

impl<'a, const B: usize, N> UnsafeUnpin for MatterStack<'a, B, N>

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