pub struct Matter<'a> { /* private fields */ }Expand description
Re-export the rs-matter crate
The primary Matter Object
Implementations§
Source§impl<'a> Matter<'a>
impl<'a> Matter<'a>
Sourcepub const fn new(
dev_det: &'a BasicInfoConfig<'a>,
dev_comm: BasicCommData,
dev_att: &'a dyn DeviceAttestation,
port: u16,
) -> Matter<'a>
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.
Sourcepub fn init(
dev_det: &'a BasicInfoConfig<'a>,
dev_comm: BasicCommData,
dev_att: &'a dyn DeviceAttestation,
port: u16,
) -> impl Init<Matter<'a>>
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.
pub fn dev_det(&self) -> &BasicInfoConfig<'_>
pub fn dev_att(&self) -> &dyn DeviceAttestation
pub fn dev_comm(&self) -> &BasicCommData
pub fn port(&self) -> u16
Sourcepub fn kv<'s, S>(&'s self, store: S) -> impl KvBlobStoreAccess + 'swhere
S: KvBlobStore + 's,
pub fn kv<'s, S>(&'s self, store: S) -> impl KvBlobStoreAccess + 'swhere
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
store- the rawKvBlobStoreimplementation to wrap
Sourcepub const fn transport(&self) -> &Transport
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.
pub fn transport_rx_buffer( &self, ) -> PacketBufferExternalAccess<'_, rs_matter::::{impl#0}::transport_rx_buffer::{constant#0}>
pub fn transport_tx_buffer( &self, ) -> PacketBufferExternalAccess<'_, rs_matter::::{impl#0}::transport_tx_buffer::{constant#0}>
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 with another one.
Sourcepub fn print_standard_qr_text(
&self,
disc_caps: DiscoveryCapabilities,
) -> Result<(), Error>
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
Sourcepub fn print_standard_qr_code(
&self,
text_type: QrTextType,
disc_caps: DiscoveryCapabilities,
) -> Result<(), Error>
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 codedisc_caps: The discovery capabilities to be used in the QR code payload
Sourcepub fn is_commissioned(&self) -> bool
pub fn is_commissioned(&self) -> bool
Return true if there is at least one commissioned fabric
Sourcepub fn open_basic_comm_window<C>(
&self,
timeout_secs: u16,
crypto: C,
notify: &dyn AttrChangeNotifier,
) -> Result<(), Error>where
C: Crypto,
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.
Sourcepub fn close_comm_window(
&self,
notify: &dyn AttrChangeNotifier,
) -> Result<bool, Error>
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.
Sourcepub fn bump_configuration_version<S>(
&self,
kv: S,
notify: &dyn AttrChangeNotifier,
) -> Result<u32, Error>where
S: KvBlobStoreAccess,
pub fn bump_configuration_version<S>(
&self,
kv: S,
notify: &dyn AttrChangeNotifier,
) -> Result<u32, Error>where
S: KvBlobStoreAccess,
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.
Sourcepub fn transport_runner<C>(&self, crypto: C) -> TransportRunner<'_, C>where
C: Crypto,
pub fn transport_runner<C>(&self, crypto: C) -> TransportRunner<'_, C>where
C: Crypto,
Create a new transport runner instance
Sourcepub async fn run<C, S, R, M>(
&self,
crypto: C,
send: S,
recv: R,
multicast: M,
) -> Result<(), Error>
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 backendsend: The network send interfacerecv: The network receive interfacemulticast: The multicast network interface (for receiving groupcast messages) When running on top of non-IP networks like BLE pass a no-op implementation likeNoNetworkhere and the multicast functionality will be disabled.
Sourcepub fn with_state<F, R>(&self, f: F) -> Rwhere
F: FnOnce(&mut MatterState) -> R,
pub fn with_state<F, R>(&self, f: F) -> Rwhere
F: FnOnce(&mut MatterState) -> R,
Access the Matter state by invoking a closure with a mutable reference to the state.
Sourcepub fn with_rtc<F, R>(&self, f: F) -> R
pub fn with_rtc<F, R>(&self, f: F) -> R
Access the Real-Time-clock by invoking a closure with a mutable reference to it.
Sourcepub fn reset_transport(&self) -> Result<(), Error>
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.
Sourcepub async fn reset_persist<K>(&self, kv: K) -> Result<(), Error>where
K: KvBlobStoreAccess,
pub async fn reset_persist<K>(&self, kv: K) -> Result<(), Error>where
K: KvBlobStoreAccess,
Reset the Matter persistable state by removing all fabrics and resetting basic info settings
Arguments:
kv: The key-value store access (obtained viaMatter::kv) to remove the fabrics and basic info settings from. Provides both the store and the scratch buffer.
Sourcepub async fn load_persist<K>(&self, kv: K) -> Result<(), Error>where
K: KvBlobStoreAccess,
pub async fn load_persist<K>(&self, kv: K) -> Result<(), Error>where
K: KvBlobStoreAccess,
Load fabrics from the given data
Arguments:
kv: The key-value store access (obtained viaMatter::kv) to load the fabrics and basic info settings from. Provides both the store and the scratch buffer.
Sourcepub fn mdns_services<F>(&self, f: F) -> Result<(), Error>
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> 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