pub struct Subscription { /* private fields */ }Expand description
What a client knows about a subscription it holds (§8.5).
The server’s half lives in subscription; this is the twin a
controller keeps. It exists for one reason: §8.5.3.2 lets the server answer with intervals
that are not the ones requested —
the publisher SHALL compute the MaxInterval … and SHALL report it in the SubscribeResponse
— so a client that assumed its own ceiling had been honoured would declare a perfectly live subscription dead, tear it down and build another, for ever.
Implementations§
Source§impl Subscription
impl Subscription
Sourcepub const fn new(response: &SubscribeResponse, now: Instant) -> Self
pub const fn new(response: &SubscribeResponse, now: Instant) -> Self
Records a subscription the publisher has just confirmed.
Sourcepub const fn max_interval_s(&self) -> u16
pub const fn max_interval_s(&self) -> u16
The MaxInterval the publisher chose — not the ceiling that was asked for.
Sourcepub fn heard(&mut self, report: &ReportData<'_>, now: Instant) -> bool
pub fn heard(&mut self, report: &ReportData<'_>, now: Instant) -> bool
Records that something arrived on this subscription.
Any report counts, including §8.5.3’s empty keep-alive: “the publisher SHALL send an empty ReportData message” when nothing has changed by the maximum interval, and its whole purpose is to be this proof of life.
Returns false — and records nothing — for a report belonging to a different
subscription. §8.5.3.2 makes the id part of every report precisely so a subscriber
holding several can tell them apart; crediting one subscription’s liveness to another
would keep a dead one alive indefinitely.
Sourcepub fn expires_at(&self) -> Instant
pub fn expires_at(&self) -> Instant
When this subscription should be considered lost (§8.5.4).
If the subscriber does not receive a report within the maximum interval … the subscriber SHALL consider the subscription to have expired.
The window is deliberately generous: MaxInterval plus the time a report needs to
traverse a lossy network and be retried by MRP. A subscriber that timed out at exactly
MaxInterval would tear down a working subscription on the first retransmission — and
a Thread network’s first retransmission is not unusual.
Sourcepub fn is_expired(&self, now: Instant) -> bool
pub fn is_expired(&self, now: Instant) -> bool
Whether the subscription has gone quiet for longer than §8.5.4 permits.