pub struct AnnounceStateMachine {
state: AnnounceState,
}Expand description
State machine for the ANNOUNCE flow. Idle → Pending → Active → Done.
Fields§
§state: AnnounceStateImplementations§
Source§impl AnnounceStateMachine
impl AnnounceStateMachine
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new machine in AnnounceState::Idle.
Sourcepub fn state(&self) -> AnnounceState
pub fn state(&self) -> AnnounceState
Returns the current state.
Sourcepub fn on_announce_sent(&mut self) -> Result<(), NamespaceError>
pub fn on_announce_sent(&mut self) -> Result<(), NamespaceError>
Idle → Pending (ANNOUNCE sent).
Sourcepub fn on_announce_ok(&mut self) -> Result<(), NamespaceError>
pub fn on_announce_ok(&mut self) -> Result<(), NamespaceError>
Pending → Active (ANNOUNCE_OK received).
Sourcepub fn on_announce_error(&mut self) -> Result<(), NamespaceError>
pub fn on_announce_error(&mut self) -> Result<(), NamespaceError>
Pending → Done (ANNOUNCE_ERROR received).
Sourcepub fn on_unannounce(&mut self) -> Result<(), NamespaceError>
pub fn on_unannounce(&mut self) -> Result<(), NamespaceError>
Active → Done (UNANNOUNCE sent — publisher withdrawing).
Sourcepub fn on_announce_cancel(&mut self) -> Result<(), NamespaceError>
pub fn on_announce_cancel(&mut self) -> Result<(), NamespaceError>
Active → Done (ANNOUNCE_CANCEL received — subscriber cancelling).
Source§impl AnnounceStateMachine
The same transitions, named for the end the advertisement arrives at.
impl AnnounceStateMachine
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 ANNOUNCE 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_announce_received(&mut self) -> Result<(), NamespaceError>
pub fn on_announce_received(&mut self) -> Result<(), NamespaceError>
Idle -> Pending (ANNOUNCE received from the peer).
Sourcepub fn on_announce_ok_sent(&mut self) -> Result<(), NamespaceError>
pub fn on_announce_ok_sent(&mut self) -> Result<(), NamespaceError>
Pending -> Active (ANNOUNCE_OK sent, accepting the announcement).
Sourcepub fn on_announce_error_sent(&mut self) -> Result<(), NamespaceError>
pub fn on_announce_error_sent(&mut self) -> Result<(), NamespaceError>
Pending -> Done (ANNOUNCE_ERROR sent, refusing the announcement).
Sourcepub fn on_unannounce_received(&mut self) -> Result<(), NamespaceError>
pub fn on_unannounce_received(&mut self) -> Result<(), NamespaceError>
Active -> Done (UNANNOUNCE received, the peer withdrawing).
Sourcepub fn on_announce_cancel_sent(&mut self) -> Result<(), NamespaceError>
pub fn on_announce_cancel_sent(&mut self) -> Result<(), NamespaceError>
Active -> Done (ANNOUNCE_CANCEL sent, revoking an acceptance).
Active is the acceptance: it is the state an announcement reaches by being answered ANNOUNCE_OK and no other way, which is why a cancellation of one never answered is refused here rather than sent.