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 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::load_persist, Matter::reset_persist, InteractionModelState::load_persist 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 is_commissioned(&self) -> bool

Return true if there is at least one commissioned fabric

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 async fn reset_persist<K>(&self, kv: K) -> Result<(), Error>

Reset the Matter persistable state by removing all fabrics and resetting basic info settings

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 async fn load_persist<K>(&self, kv: K) -> Result<(), Error>

Load fabrics from the given data

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