pub struct Subscription { /* private fields */ }Expand description
A live attribute subscription. Await events with Self::next; dropping
the handle cancels the subscription (best-effort).
Steady-state SubscriptionEvent::Reports are buffered in a bounded
channel (capacity SUBSCRIPTION_CHANNEL_CAP, 256) so a device — whose reporting
cadence and per-report size are attacker-controlled — cannot drive unbounded
controller memory growth. If the consumer does not call Self::next
promptly and the buffer fills, excess reports are dropped and a
SubscriptionEvent::Lagged event reports how many were lost.
Control events (SubscriptionEvent::Established and
SubscriptionEvent::Resubscribing) travel on a separate, low-volume channel
and are delivered reliably even while reports are being dropped; they are
also prioritised by Self::next.
Implementations§
Source§impl Subscription
impl Subscription
Sourcepub async fn next(&mut self) -> Option<SubscriptionEvent>
pub async fn next(&mut self) -> Option<SubscriptionEvent>
Await the next subscription event, or None once the subscription has
ended (cancelled, or the controller task stopped).
Control events (SubscriptionEvent::Established /
SubscriptionEvent::Resubscribing) are prioritised over buffered
reports, so a re-establishment is observed promptly even behind a backlog.