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 (REQUEST_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>
REQUEST_UPDATE received – a self-transition, from Subscribing as well as from Active.
Section 9.11 orders an update against the request rather than against the request’s answer: the sender of a SUBSCRIBE “can later send a REQUEST_UPDATE to modify it”, where later is later than the SUBSCRIBE. The message names what it updates in its own Existing Request ID field, which the SUBSCRIBE has already established.
So a peer that sends SUBSCRIBE and REQUEST_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_request_error_sent(&mut self) -> Result<(), SubscriptionError>
pub fn on_request_error_sent(&mut self) -> Result<(), SubscriptionError>
Subscribing -> Done (REQUEST_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_request_update_received(&mut self) -> Result<(), SubscriptionError>
pub fn on_request_update_received(&mut self) -> Result<(), SubscriptionError>
Subscribing or Active, unchanged (REQUEST_UPDATE received from the subscribing peer).