pub struct PublishNamespaceStateMachine {
state: PublishNamespaceState,
}Expand description
State machine for PUBLISH_NAMESPACE flow. Idle → Pending → Active → Done.
Fields§
§state: PublishNamespaceStateImplementations§
Source§impl PublishNamespaceStateMachine
impl PublishNamespaceStateMachine
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new machine in PublishNamespaceState::Idle.
Sourcepub fn state(&self) -> PublishNamespaceState
pub fn state(&self) -> PublishNamespaceState
Returns the current state of the publish-namespace flow.
Sourcepub fn on_publish_namespace_sent(&mut self) -> Result<(), NamespaceError>
pub fn on_publish_namespace_sent(&mut self) -> Result<(), NamespaceError>
Idle → Pending.
Sourcepub fn on_publish_namespace_ok(&mut self) -> Result<(), NamespaceError>
pub fn on_publish_namespace_ok(&mut self) -> Result<(), NamespaceError>
Pending → Active.
Sourcepub fn on_publish_namespace_error(&mut self) -> Result<(), NamespaceError>
pub fn on_publish_namespace_error(&mut self) -> Result<(), NamespaceError>
Pending → Done.
Sourcepub fn on_publish_namespace_done(&mut self) -> Result<(), NamespaceError>
pub fn on_publish_namespace_done(&mut self) -> Result<(), NamespaceError>
Active → Done (publisher withdrawing).
Sourcepub fn on_publish_namespace_cancel(&mut self) -> Result<(), NamespaceError>
pub fn on_publish_namespace_cancel(&mut self) -> Result<(), NamespaceError>
Active → Done (subscriber cancelling).
Source§impl PublishNamespaceStateMachine
The same transitions, named for the end the advertisement arrives at.
impl PublishNamespaceStateMachine
The same transitions, named for the end the advertisement arrives at.
An announcement this endpoint accepts passes through the states in the same order as one it makes, with every message going the other way: the PUBLISH_NAMESPACE arrives instead of leaving, the answer leaves instead of arriving, the withdrawal arrives and the cancellation leaves. 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_publish_namespace_received(&mut self) -> Result<(), NamespaceError>
pub fn on_publish_namespace_received(&mut self) -> Result<(), NamespaceError>
Idle -> Pending (PUBLISH_NAMESPACE received from the peer).
Sourcepub fn on_publish_namespace_ok_sent(&mut self) -> Result<(), NamespaceError>
pub fn on_publish_namespace_ok_sent(&mut self) -> Result<(), NamespaceError>
Pending -> Active (PUBLISH_NAMESPACE_OK sent, accepting the announcement).
Sourcepub fn on_publish_namespace_error_sent(&mut self) -> Result<(), NamespaceError>
pub fn on_publish_namespace_error_sent(&mut self) -> Result<(), NamespaceError>
Pending -> Done (PUBLISH_NAMESPACE_ERROR sent, refusing the announcement).
Sourcepub fn on_publish_namespace_done_received(
&mut self,
) -> Result<(), NamespaceError>
pub fn on_publish_namespace_done_received( &mut self, ) -> Result<(), NamespaceError>
Active -> Done (PUBLISH_NAMESPACE_DONE received, the peer withdrawing).
Sourcepub fn on_publish_namespace_cancel_sent(&mut self) -> Result<(), NamespaceError>
pub fn on_publish_namespace_cancel_sent(&mut self) -> Result<(), NamespaceError>
Active -> Done (PUBLISH_NAMESPACE_CANCEL sent, revoking an acceptance).
Active is the acceptance: it is the state an announcement reaches by being answered PUBLISH_NAMESPACE_OK and no other way, which is why a cancellation of one never answered is refused here rather than sent.