Skip to main content

Subscription

Struct Subscription 

Source
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

Source

pub const fn new(response: &SubscribeResponse, now: Instant) -> Self

Records a subscription the publisher has just confirmed.

Source

pub const fn id(&self) -> u32

The id every report of this subscription carries.

Source

pub const fn max_interval_s(&self) -> u16

The MaxInterval the publisher chose — not the ceiling that was asked for.

Source

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.

Source

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.

Source

pub fn is_expired(&self, now: Instant) -> bool

Whether the subscription has gone quiet for longer than §8.5.4 permits.

Trait Implementations§

Source§

impl Clone for Subscription

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Subscription

Source§

impl Debug for Subscription

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for Subscription

Source§

impl PartialEq for Subscription

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Subscription

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.