pub struct SubscriptionStateMachine {
state: SubscriptionState,
}Expand description
Pure state machine for a MoQT subscription. Transitions: Idle → Subscribing → Active → Done.
Fields§
§state: SubscriptionStateImplementations§
Source§impl SubscriptionStateMachine
impl SubscriptionStateMachine
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new state machine in the SubscriptionState::Idle state.
Sourcepub fn state(&self) -> SubscriptionState
pub fn state(&self) -> SubscriptionState
Returns the current state of the subscription.
Sourcepub fn on_subscribe_sent(&mut self) -> Result<(), SubscriptionError>
pub fn on_subscribe_sent(&mut self) -> Result<(), SubscriptionError>
Idle → Subscribing (SUBSCRIBE sent).
Sourcepub fn on_subscribe_ok(&mut self) -> Result<(), SubscriptionError>
pub fn on_subscribe_ok(&mut self) -> Result<(), SubscriptionError>
Subscribing → Active (SUBSCRIBE_OK received).
Sourcepub fn on_subscribe_error(&mut self) -> Result<(), SubscriptionError>
pub fn on_subscribe_error(&mut self) -> Result<(), SubscriptionError>
Subscribing → Done (SUBSCRIBE_ERROR received).
Sourcepub fn on_unsubscribe(&mut self) -> Result<(), SubscriptionError>
pub fn on_unsubscribe(&mut self) -> Result<(), SubscriptionError>
Active → Done (UNSUBSCRIBE sent).
Sourcepub fn on_subscribe_update(&mut self) -> Result<(), SubscriptionError>
pub fn on_subscribe_update(&mut self) -> Result<(), SubscriptionError>
SUBSCRIBE_UPDATE received – a self-transition, from Subscribing as well as from Active.
Section 9.10 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 Request ID” — and a Request 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.
Sourcepub fn on_publish_done(&mut self) -> Result<(), SubscriptionError>
pub fn on_publish_done(&mut self) -> Result<(), SubscriptionError>
Active → Done (PUBLISH_DONE received).
Source§impl SubscriptionStateMachine
The same six transitions, named for the end that sees them.
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.
Sourcepub fn on_subscribe_received(&mut self) -> Result<(), SubscriptionError>
pub fn on_subscribe_received(&mut self) -> Result<(), SubscriptionError>
Idle -> Subscribing (SUBSCRIBE received from a subscribing peer).
Sourcepub fn on_subscribe_ok_sent(&mut self) -> Result<(), SubscriptionError>
pub fn on_subscribe_ok_sent(&mut self) -> Result<(), SubscriptionError>
Subscribing -> Active (SUBSCRIBE_OK sent to the subscribing peer).
Sourcepub fn on_subscribe_error_sent(&mut self) -> Result<(), SubscriptionError>
pub fn on_subscribe_error_sent(&mut self) -> Result<(), SubscriptionError>
Subscribing -> Done (SUBSCRIBE_ERROR sent to the subscribing peer).
Sourcepub fn on_unsubscribe_received(&mut self) -> Result<(), SubscriptionError>
pub fn on_unsubscribe_received(&mut self) -> Result<(), SubscriptionError>
Active -> Done (UNSUBSCRIBE received from the subscribing peer).
Sourcepub fn on_publish_done_sent(&mut self) -> Result<(), SubscriptionError>
pub fn on_publish_done_sent(&mut self) -> Result<(), SubscriptionError>
Active -> Done (PUBLISH_DONE sent to the subscribing peer).
Sourcepub fn on_subscribe_update_received(&mut self) -> Result<(), SubscriptionError>
pub fn on_subscribe_update_received(&mut self) -> Result<(), SubscriptionError>
Subscribing or Active, unchanged (SUBSCRIBE_UPDATE received from the subscribing peer).