Skip to main content

SubscriptionStateMachine

Struct SubscriptionStateMachine 

Source
pub struct SubscriptionStateMachine {
    state: SubscriptionState,
}
Expand description

Pure state machine for a MoQT subscription (draft-10). Transitions: Idle → Subscribing → Active → Done.

Fields§

§state: SubscriptionState

Implementations§

Source§

impl SubscriptionStateMachine

Source

pub fn new() -> Self

Creates a new state machine in the SubscriptionState::Idle state.

Source

pub fn state(&self) -> SubscriptionState

Returns the current state of the subscription.

Source

pub fn on_subscribe_sent(&mut self) -> Result<(), SubscriptionError>

Idle → Subscribing (SUBSCRIBE sent).

Source

pub fn on_subscribe_ok(&mut self) -> Result<(), SubscriptionError>

Subscribing → Active (SUBSCRIBE_OK received).

Source

pub fn on_subscribe_error(&mut self) -> Result<(), SubscriptionError>

Subscribing → Done (SUBSCRIBE_ERROR received).

Source

pub fn on_unsubscribe(&mut self) -> Result<(), SubscriptionError>

Active → Done (UNSUBSCRIBE sent).

Source

pub fn on_subscribe_update(&mut self) -> Result<(), SubscriptionError>

SUBSCRIBE_UPDATE received – a self-transition, from Subscribing as well as from Active.

Section 8.9 orders an update against the subscription rather than against the subscription’s answer. All it asks of the identifier is that it already name something: “This MUST match an existing Subscribe ID” — and a Subscribe ID exists from the moment the SUBSCRIBE carrying it is sent, not from the moment it is answered.

So a peer that sends SUBSCRIBE and SUBSCRIBE_UPDATE back to back breaks no rule this draft states, and an update arriving before the answer leaves the subscription where it found it. Idle and Done are still refused: in neither does the subscription an update names exist.

Source

pub fn on_subscribe_done(&mut self) -> Result<(), SubscriptionError>

Active → Done (SUBSCRIBE_DONE received — publisher finished).

Source§

impl SubscriptionStateMachine

The same six transitions, named for the end that sees them.

A subscription this endpoint publishes runs through the states in the same order as one it subscribes to, with every message going the other way: the SUBSCRIBE arrives instead of leaving, the answer leaves instead of arriving. Sharing the transitions and not the names is what lets a refusal say which event was refused, rather than naming the mirror image of it.

Source

pub fn on_subscribe_received(&mut self) -> Result<(), SubscriptionError>

Idle -> Subscribing (SUBSCRIBE received from a subscribing peer).

Source

pub fn on_subscribe_ok_sent(&mut self) -> Result<(), SubscriptionError>

Subscribing -> Active (SUBSCRIBE_OK sent to the subscribing peer).

Source

pub fn on_subscribe_error_sent(&mut self) -> Result<(), SubscriptionError>

Subscribing -> Done (SUBSCRIBE_ERROR sent to the subscribing peer).

Source

pub fn on_unsubscribe_received(&mut self) -> Result<(), SubscriptionError>

Active -> Done (UNSUBSCRIBE received from the subscribing peer).

Source

pub fn on_subscribe_done_sent(&mut self) -> Result<(), SubscriptionError>

Active -> Done (SUBSCRIBE_DONE sent to the subscribing peer).

Source

pub fn on_subscribe_update_received(&mut self) -> Result<(), SubscriptionError>

Subscribing or Active, unchanged (SUBSCRIBE_UPDATE received from the subscribing peer).

Trait Implementations§

Source§

impl Default for SubscriptionStateMachine

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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, 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.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more