pub struct Runtime<C: Config, const S: usize = 16, const X: usize = 64, const I: usize = 8, const R: usize = 4, const Q: usize = 4, const B: usize = SCRATCH> { /* private fields */ }rustcrypto only.Expand description
The node runtime.
S sessions and X exchanges size the messaging stack (Messaging’s own defaults); I
interactions in progress; R datagrams kept for retransmission; Q datagrams queued for
sending; B octets of attribute scratch (SCRATCH). The defaults fit DefaultConfig
and satisfy every specification minimum for five fabrics; a device with less RAM lowers
I, R and Q first.
About 60 KiB with the defaults, almost all of it datagram buffers and the subscription
table, so a device puts it in a static rather than on a task’s stack.
Implementations§
Source§impl<C: Config, const S: usize, const X: usize, const I: usize, const R: usize, const Q: usize, const B: usize> Runtime<C, S, X, I, R, Q, B>
impl<C: Config, const S: usize, const X: usize, const I: usize, const R: usize, const Q: usize, const B: usize> Runtime<C, S, X, I, R, Q, B>
Sourcepub async fn run<K, G, H, Ac, Gk, Ev, V, U, M, T, const F: usize, const AF: usize, const A: usize>(
&mut self,
device: &Device<'_, C, K, G, H, Ac, Gk, Ev, V, F>,
matter: &U,
mdns: Mdns<'_, M>,
advertiser: &mut Advertiser<AF, A>,
timer: &T,
on_notice: impl FnMut(Notice),
) -> !where
K: KeyStore,
G: Rng,
H: ClusterHandler,
Ac: AccessList,
Gk: GroupKeyStore,
Ev: EventLog,
V: ChangeLog,
U: Udp,
M: Udp,
T: Timer,
pub async fn run<K, G, H, Ac, Gk, Ev, V, U, M, T, const F: usize, const AF: usize, const A: usize>(
&mut self,
device: &Device<'_, C, K, G, H, Ac, Gk, Ev, V, F>,
matter: &U,
mdns: Mdns<'_, M>,
advertiser: &mut Advertiser<AF, A>,
timer: &T,
on_notice: impl FnMut(Notice),
) -> !where
K: KeyStore,
G: Rng,
H: ClusterHandler,
Ac: AccessList,
Gk: GroupKeyStore,
Ev: EventLog,
V: ChangeLog,
U: Udp,
M: Udp,
T: Timer,
Runs the node: Matter datagrams, mDNS queries, timers, for ever.
Every iteration does the time-driven work first (Runtime::poll) and only then waits,
whichever source woke it. A select that returns the first ready source starves whichever
it polls last, and both orderings fail: sockets first starves the timer on a link with
steady mDNS traffic, timer first starves the sockets the moment any deadline is overdue.
Waiting may prefer the sockets because nothing time-driven happens in it.
on_notice hears every Notice, in order.
Source§impl<C: Config, const S: usize, const X: usize, const I: usize, const R: usize, const Q: usize, const B: usize> Runtime<C, S, X, I, R, Q, B>
impl<C: Config, const S: usize, const X: usize, const I: usize, const R: usize, const Q: usize, const B: usize> Runtime<C, S, X, I, R, Q, B>
Sourcepub fn with_max_paths_per_invoke(self, max: u16) -> Self
pub fn with_max_paths_per_invoke(self, max: u16) -> Self
Sets MaxPathsPerInvoke (§8.8.2.3) — what Basic Information advertises.
Sourcepub const fn messaging_mut(&mut self) -> &mut Messaging<C, S, X>
pub const fn messaging_mut(&mut self) -> &mut Messaging<C, S, X>
The messaging stack, for installing a session directly or registering protocols.
Sourcepub const fn subscriptions(&self) -> &Subscriptions<C>
pub const fn subscriptions(&self) -> &Subscriptions<C>
The subscriptions.
Sourcepub fn transmit(&mut self) -> Option<(Peer, &[u8])>
pub fn transmit(&mut self) -> Option<(Peer, &[u8])>
The next datagram to send, and where. Valid until the next call.
Sourcepub fn receive<K, G, H, Ac, Gk, Ev, V, const F: usize>(
&mut self,
device: &Device<'_, C, K, G, H, Ac, Gk, Ev, V, F>,
datagram: &mut [u8],
from: Peer,
now: Instant,
)where
K: KeyStore,
G: Rng,
H: ClusterHandler,
Ac: AccessList,
Gk: GroupKeyStore,
Ev: EventLog,
V: ChangeLog,
pub fn receive<K, G, H, Ac, Gk, Ev, V, const F: usize>(
&mut self,
device: &Device<'_, C, K, G, H, Ac, Gk, Ev, V, F>,
datagram: &mut [u8],
from: Peer,
now: Instant,
)where
K: KeyStore,
G: Rng,
H: ClusterHandler,
Ac: AccessList,
Gk: GroupKeyStore,
Ev: EventLog,
V: ChangeLog,
One datagram in.
Whatever it owes — a reply, an acknowledgement, a CloseSession to an evicted peer — is
queued for Self::transmit. datagram is decrypted in place.
Sourcepub fn poll<K, G, H, Ac, Gk, Ev, V, const F: usize>(
&mut self,
device: &Device<'_, C, K, G, H, Ac, Gk, Ev, V, F>,
now: Instant,
)where
K: KeyStore,
G: Rng,
H: ClusterHandler,
Ac: AccessList,
Gk: GroupKeyStore,
Ev: EventLog,
V: ChangeLog,
pub fn poll<K, G, H, Ac, Gk, Ev, V, const F: usize>(
&mut self,
device: &Device<'_, C, K, G, H, Ac, Gk, Ev, V, F>,
now: Instant,
)where
K: KeyStore,
G: Rng,
H: ClusterHandler,
Ac: AccessList,
Gk: GroupKeyStore,
Ev: EventLog,
V: ChangeLog,
Everything time-driven.
Call it whenever Self::next_deadline passes, and after every Self::receive — the
driver does both on every iteration, whichever event woke it, because a loop that runs
time-driven work only when the timer wins a race against the sockets starves one or the
other.
Sourcepub fn next_deadline<K, G, H, Ac, Gk, Ev, V, const F: usize>(
&self,
device: &Device<'_, C, K, G, H, Ac, Gk, Ev, V, F>,
) -> Option<Instant>where
K: KeyStore,
G: Rng,
H: ClusterHandler,
Ac: AccessList,
Gk: GroupKeyStore,
Ev: EventLog,
V: ChangeLog,
pub fn next_deadline<K, G, H, Ac, Gk, Ev, V, const F: usize>(
&self,
device: &Device<'_, C, K, G, H, Ac, Gk, Ev, V, F>,
) -> Option<Instant>where
K: KeyStore,
G: Rng,
H: ClusterHandler,
Ac: AccessList,
Gk: GroupKeyStore,
Ev: EventLog,
V: ChangeLog,
The earliest instant Self::poll has work, if any.