Expand description
The seams between this crate and the machine it runs on.
Matter needs sockets, a clock, randomness, storage and cryptography. None of those is
the protocol, and every one of them differs between a Linux bridge, an ESP32 and a
simulator. So they are traits, and the crate names no implementation of them: there is
no tokio and no embassy-time in its dependency tree, and a consumer who has already
chosen an executor keeps it.
The traits are deliberately small. A platform is a handful of async fns, not a
framework.
§What is here
| Trait | For |
|---|---|
Timer | monotonic time and sleeping — every deadline in the specification |
Clock | wall-clock UTC, which only the Time Synchronization cluster needs |
Rng | cryptographically secure random bytes |
Udp | IPv6 datagrams, the transport every Matter node must have |
KvStore | opaque, versioned blobs that survive a reboot |
Each has an implementation in sim — an in-process network with a virtual clock —
and, with the std feature, in crate::platform::os.
§Why the clock is a trait, and not Instant::now()
Because half of Matter is timers. MRP retransmits on a backoff curve; a fail-safe expires; an intermittently-connected device sleeps for an hour and wakes to check in; a subscription dies if no report arrives inside its interval. Testing any of that against a real clock means waiting, which means those paths get tested rarely, shallowly, and flakily.
With time as a parameter, sim::SimNet advances to the next scheduled deadline
instantly, so an hour-long intermittently-connected scenario is a unit test that
finishes in microseconds and fails the same way every time.
Modules§
- os
std - The platform traits on an operating system, with no async runtime.
- sim
- An in-process network with a virtual clock.
Structs§
- Duration
- A span of time, in microseconds.
- Instant
- A point on a monotonic timeline.
- NoClock
- A node with no real-time clock.
- Peer
Addr - An IPv6 address and port — where a Matter message came from, or goes to.
Enums§
- Granularity
- How precisely a node knows the time (Core §11.17,
GranularityEnum). - Peer
- Where a Matter message came from, or goes to, whichever transport carried it.