pub struct SubscribeNamespaceStateMachine {
state: SubscribeNamespaceState,
}Expand description
State machine for SUBSCRIBE_NAMESPACE flow. Idle → Pending → Active → Done.
Fields§
§state: SubscribeNamespaceStateImplementations§
Source§impl SubscribeNamespaceStateMachine
impl SubscribeNamespaceStateMachine
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new machine in SubscribeNamespaceState::Idle.
Sourcepub fn state(&self) -> SubscribeNamespaceState
pub fn state(&self) -> SubscribeNamespaceState
Returns the current state of the subscribe-namespace flow.
Sourcepub fn on_subscribe_namespace_sent(&mut self) -> Result<(), NamespaceError>
pub fn on_subscribe_namespace_sent(&mut self) -> Result<(), NamespaceError>
Idle → Pending.
Sourcepub fn on_subscribe_namespace_ok(&mut self) -> Result<(), NamespaceError>
pub fn on_subscribe_namespace_ok(&mut self) -> Result<(), NamespaceError>
Pending → Active.
Sourcepub fn on_subscribe_namespace_error(&mut self) -> Result<(), NamespaceError>
pub fn on_subscribe_namespace_error(&mut self) -> Result<(), NamespaceError>
Pending → Done.
Sourcepub fn on_unsubscribe_namespace(&mut self) -> Result<(), NamespaceError>
pub fn on_unsubscribe_namespace(&mut self) -> Result<(), NamespaceError>
Active → Done.
Sourcepub fn on_subscribe_namespace_received(&mut self) -> Result<(), NamespaceError>
pub fn on_subscribe_namespace_received(&mut self) -> Result<(), NamespaceError>
Idle → Pending (a SUBSCRIBE_NAMESPACE arrived from the peer).
The mirror of
on_subscribe_namespace_sent,
named for the direction it runs in rather than shared with it: the two
state edges coincide, so a message dispatched to the wrong one of them
would move the record silently instead of naming the event it was not.
Sourcepub fn on_subscribe_namespace_ok_sent(&mut self) -> Result<(), NamespaceError>
pub fn on_subscribe_namespace_ok_sent(&mut self) -> Result<(), NamespaceError>
Pending → Active (this endpoint accepted the peer’s request with a SUBSCRIBE_NAMESPACE_OK).
Section 6.1: “A publisher MUST send exactly one SUBSCRIBE_NAMESPACE_OK or SUBSCRIBE_NAMESPACE_ERROR in response to a SUBSCRIBE_NAMESPACE.”
One answer and no second one: the record leaves Pending on the first, and a second call finds it somewhere else.
Sourcepub fn on_subscribe_namespace_error_sent(
&mut self,
) -> Result<(), NamespaceError>
pub fn on_subscribe_namespace_error_sent( &mut self, ) -> Result<(), NamespaceError>
Pending → Done (this endpoint refused the peer’s request with a SUBSCRIBE_NAMESPACE_ERROR).
The other half of the same sentence: one message back, and this is the other one it can be.
Sourcepub fn on_unsubscribe_namespace_received(
&mut self,
) -> Result<(), NamespaceError>
pub fn on_unsubscribe_namespace_received( &mut self, ) -> Result<(), NamespaceError>
Active → Done (the peer withdrew the namespace subscription with an UNSUBSCRIBE_NAMESPACE).
Section 6.1: “An UNSUBSCRIBE_NAMESPACE withdraws a previous SUBSCRIBE_NAMESPACE.”
Active is the acceptance, which is the state a namespace subscription reaches by being answered SUBSCRIBE_NAMESPACE_OK and no other way, so a withdrawal of one never answered is refused here.