Skip to main content

Matter

Struct Matter 

Source
pub struct Matter<'a> { /* private fields */ }
Expand description

Re-export the rs-matter crate The primary Matter Object

Implementations§

Source§

impl<'a> Matter<'a>

Source

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

Create a new Matter object.

§Parameters
  • dev_det: An object of type BasicInfoConfig.
  • dev_comm: An object of type BasicCommData. This object contains the basic commissioning data required for the device.
  • dev_att: An object that implements the trait [DevAttDataFetcher]. Any Matter device requires a set of device attestation certificates and keys. It is the responsibility of this object to return the device attestation details when queried upon.
  • port: The port number on which the Matter stack will listen for incoming connections.
Source

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

Create an in-place initializer for a Matter object.

§Parameters
  • dev_det: An object of type BasicInfoConfig.
  • dev_comm: An object of type BasicCommData. This object contains the basic commissioning data required for the device.
  • dev_att: An object that implements the trait [DevAttDataFetcher]. Any Matter device requires a set of device attestation certificates and keys. It is the responsibility of this object to return the device attestation details when queried upon.
  • port: The port number on which the Matter stack will listen for incoming connections.
Source

pub fn dev_det(&self) -> &BasicInfoConfig<'_>

Source

pub fn dev_att(&self) -> &dyn DeviceAttestation

Source

pub fn dev_comm(&self) -> &BasicCommData

Source

pub fn port(&self) -> u16

Source

pub fn icd_mode(&self) -> Option<OperatingModeEnum>

The ICD operating mode to advertise in the operational ICD DNS-SD TXT key, or None when the device is not a Long-Idle-Time ICD.

Source

pub fn set_icd_mode(&self, mode: Option<OperatingModeEnum>)

Set the ICD operating mode advertised in mDNS and, if it changed, signal the mDNS layer to re-publish.

Source

pub fn kv<'s, S>(&'s self, store: S) -> impl KvBlobStoreAccess + 's
where S: KvBlobStore + 's,

Combine a user-provided raw KvBlobStore with the scratch buffer owned by this Matter object to obtain a full KvBlobStoreAccess.

This is the single entry point for persistence: the application passes its raw store (sync load/store/remove) and gets back an access object that recombines it with Matter’s feature-sized scratch buffer (see KV_BUF_SIZE). The returned value is then lent (by &) to Matter::startup, Matter::factory_reset and InteractionModel::new.

§Arguments
Source

pub const fn transport(&self) -> &Transport

Get a reference to the transport state of this Matter object.

All transport-related state and operations (mDNS change/resolve rendezvous, session/group notifications, RX/TX buffers, exchange initiation/acceptance) live on Transport.

Source

pub fn transport_rx_buffer( &self, ) -> PacketBufferExternalAccess<'_, rs_matter::::{impl#0}::transport_rx_buffer::{constant#0}>

Source

pub fn transport_tx_buffer( &self, ) -> PacketBufferExternalAccess<'_, rs_matter::::{impl#0}::transport_tx_buffer::{constant#0}>

Source

pub fn replace_dev_att(&mut self, dev_att: &'a dyn DeviceAttestation)

A utility method to replace the initial Device Attestation with another one.

Source

pub fn print_standard_qr_text( &self, disc_caps: DiscoveryCapabilities, ) -> Result<(), Error>

Print the standard QR code text to the console

The printed QR code text corresponds to the standard commissioning flow (i.e. CommFlowType::Standard) and contains no optional data.

This method is useful primarily during development, when the Matter device is attached to a console. It is expected that the developer will call this method prior to running the Matter transport.

§Arguments
  • disc_caps: The discovery capabilities to be used in the QR code payload
Source

pub fn print_standard_qr_code( &self, text_type: QrTextType, disc_caps: DiscoveryCapabilities, ) -> Result<(), Error>

Print the standard QR code to the console

The printed QR code corresponds to the standard commissioning flow (i.e. CommFlowType::Standard) and contains no optional data.

This method is useful primarily during development, when the Matter device is attached to a console. It is expected that the developer will call this method prior to running the Matter transport.

§Arguments
  • text_type: The type of text representation to use when printing the QR code
  • disc_caps: The discovery capabilities to be used in the QR code payload
Source

pub fn has_fabrics(&self) -> bool

Return true if there is at least one fabric.

Note that this is emphatically not “the device is commissioned”: a fabric is created as soon as AddNOC is received, which is well before the commissioner has established a CASE session over the operational network and sent CommissioningComplete. Code that needs to know whether commissioning is still in progress should use [Matter::is_comm_window_open] instead, as the commissioning window stays open for exactly that long.

Source

pub fn comm_window_state(&self) -> CommWindowState

Return the state of the commissioning window - whether one is open, and if so who opened it. See CommWindowState for what the answer is good for.

Source

pub fn open_basic_comm_window<C>( &self, timeout_secs: u16, crypto: C, notify: &dyn AttrChangeNotifier, ) -> Result<(), Error>
where C: Crypto,

Open a basic commissioning window

The method will return an error if the commissioning window cannot be opened (due to another window already being opened, for example).

§Arguments
  • timeout_secs: The timeout in seconds for the basic commissioning window

Note: This is the low-level building block that mutates PASE state and routes a notify_cluster_changed(...) to subscribers via notify, but does not bump the per-cluster Dataver of AdministratorCommissioning — a subsequent dataver-filtered read could therefore cache-hit and miss the change. Application code that holds a InteractionModel should prefer crate::im::InteractionModel::open_basic_comm_window, which delegates here and additionally bumps dataver via its AttrChangeNotifier impl.

Source

pub fn close_comm_window( &self, notify: &dyn AttrChangeNotifier, ) -> Result<bool, Error>

Close the commissioning window (basic or other)

The method will return Ok(false) if there is no active PASE commissioning window to close.

Note: As with Matter::open_basic_comm_window, this does not bump the per-cluster Dataver of AdministratorCommissioning. Prefer crate::im::InteractionModel::close_comm_window when a InteractionModel is available.

Source

pub fn bump_configuration_version<S>( &self, kv: S, notify: &dyn AttrChangeNotifier, ) -> Result<u32, Error>

Bump BasicInformation::ConfigurationVersion by one, persist the new value via kv, and route an attribute-change notification to subscribers via notify.

Per Matter Core Spec, the device MUST bump this attribute on any change to its exposed fixed-quality surface (a firmware update that adds or removes functionality, internal reconfiguration that changes any F-quality attribute, bridged-node add/remove on a bridge). rs-matter cannot detect such events on its own — the application drives the bump.

Note: Like the other low-level mutators on Matter, this does not bump the per-cluster Dataver of BasicInformation. A subsequent dataver-filtered read could therefore cache-hit and miss the change. Application code that holds a InteractionModel should prefer crate::im::InteractionModel::bump_configuration_version, which delegates here and additionally bumps dataver via its AttrChangeNotifier impl.

Returns the new ConfigurationVersion value.

Source

pub fn transport_runner<C>(&self, crypto: C) -> TransportRunner<'_, C>
where C: Crypto,

Create a new transport runner instance

Source

pub async fn run<C, S, R, M>( &self, crypto: C, send: S, recv: R, multicast: M, ) -> Result<(), Error>

Run the Matter transport layer.

§Arguments
  • crypto: The crypto backend
  • send: The network send interface
  • recv: The network receive interface
  • multicast: The multicast network interface (for receiving groupcast messages) When running on top of non-IP networks like BLE pass a no-op implementation like NoNetwork here and the multicast functionality will be disabled.
Source

pub fn with_state<F, R>(&self, f: F) -> R
where F: FnOnce(&mut MatterState) -> R,

Access the Matter state by invoking a closure with a mutable reference to the state.

Source

pub fn with_rtc<F, R>(&self, f: F) -> R
where F: FnOnce(&mut Rtc) -> R,

Access the Real-Time-clock by invoking a closure with a mutable reference to it.

Source

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

Reset the transport layer by clearing all sessions, exchanges, the RX buffer and the TX buffer NOTE: User should be careful not to call this method while the transport layer and/or the built-in mDNS is running.

Source

pub fn factory_reset<K>(&self, kv: K) -> Result<(), Error>

Factory-reset the Matter persistable state by removing all fabrics and resetting the basic info settings, the RTC state and (if compiled in) the CASE resumption cache and the group data message counter - both in-memory and in the provided KV store.

The counterpart of Matter::startup. Call when the node is factory-reset, alongside InteractionModel::factory_reset.

Arguments:

  • kv: The key-value store access (obtained via Matter::kv) to remove the fabrics and basic info settings from. Provides both the store and the scratch buffer.
Source

pub fn startup<K>(&self, kv: K) -> Result<(), Error>

Re-hydrate the Matter persistable state - the fabrics, the basic info settings, the RTC state and (if compiled in) the CASE resumption cache and the group data message counter - from the provided KV store.

Call once at startup, before the transport starts serving traffic. The Data-Model counterpart is InteractionModel::startup.

Arguments:

  • kv: The key-value store access (obtained via Matter::kv) to load the fabrics and basic info settings from. Provides both the store and the scratch buffer.
Source

pub fn mdns_services<F>(&self, f: F) -> Result<(), Error>

Invoke the given closure for each currently published Matter mDNS service.

Auto Trait Implementations§

§

impl<'a> !Freeze for Matter<'a>

§

impl<'a> !RefUnwindSafe for Matter<'a>

§

impl<'a> !Send for Matter<'a>

§

impl<'a> !Sync for Matter<'a>

§

impl<'a> !UnwindSafe for Matter<'a>

§

impl<'a> Unpin for Matter<'a>

§

impl<'a> UnsafeUnpin for Matter<'a>

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