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 on_subscribe_received(&mut self) -> Result<(), SubscriptionError>
pub fn on_subscribe_received(&mut self) -> Result<(), SubscriptionError>
Idle -> Subscribing (SUBSCRIBE received from the 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 written on the peer’s stream).
Sourcepub fn on_subscribe_error_sent(&mut self) -> Result<(), SubscriptionError>
pub fn on_subscribe_error_sent(&mut self) -> Result<(), SubscriptionError>
Subscribing -> Done (REQUEST_ERROR written on the peer’s stream).
Sourcepub fn on_publish_done_sent(&mut self) -> Result<(), SubscriptionError>
pub fn on_publish_done_sent(&mut self) -> Result<(), SubscriptionError>
Active -> Done (PUBLISH_DONE written on the peer’s stream).
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_request_cancelled(&mut self) -> Result<(), SubscriptionError>
pub fn on_request_cancelled(&mut self) -> Result<(), SubscriptionError>
Subscribing | Active -> Done, Done -> Done (this subscription’s request stream was cancelled).
This draft has no UNSUBSCRIBE message. Section 3.3.1: “Once a request stream has been opened, the request MAY be cancelled by either endpoint.”
Subscribing is accepted because the precondition is the stream being
open, and it is open from the SUBSCRIBE that opened it: a subscription
can be withdrawn before it is ever answered.
Idle is refused, on the other half of the same sentence: nothing has
been written, so there is no stream to terminate. Done stays Done —
nothing finishes a request stream’s send half on the ordinary path, so a
caller that walks away from a request that has already ended still
resets the stream, and that reset is an ordinary end rather than a
fault.
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.10 orders an update against the request rather than against the request’s answer: the sender of a SUBSCRIBE “can later send a REQUEST_UPDATE on the same bidi stream as the request to modify it”, where later is later than the SUBSCRIBE. The stream is open from the moment the SUBSCRIBE opens it.
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).