#[non_exhaustive]pub enum PeerState {
Bootstrapped {
versions_url: Url,
token_a: CredentialsToken,
},
Registered {
version: VersionNumber,
our_token_for_them: CredentialsToken,
their_token_for_us: CredentialsToken,
parties: Vec<PartyRef>,
},
Unregistered,
}client only.Expand description
Where a connection with one peer stands.
The transitions between these are the ones the specification defines; storing this enum is how a process remembers a registration across restarts.
Spec: 2.3.0 §credentials_use_cases
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Bootstrapped
CREDENTIALS_TOKEN_A has been exchanged out of band; nothing else has happened.
The token may only be used on the credentials and versions modules.
Fields
token_a: CredentialsTokenCREDENTIALS_TOKEN_A.
Registered
The handshake completed.
Fields
version: VersionNumberThe version in use.
our_token_for_them: CredentialsTokenThe token this party uses to call the peer (CREDENTIALS_TOKEN_C for the Sender).
their_token_for_us: CredentialsTokenThe token the peer uses to call this party (CREDENTIALS_TOKEN_B for the Sender).
Unregistered
A DELETE on the credentials module ended the connection.
Both parties must end any automated communication.
Implementations§
Source§impl PeerState
impl PeerState
Sourcepub const fn may_use_functional_modules(&self) -> bool
pub const fn may_use_functional_modules(&self) -> bool
Whether requests to functional modules are allowed in this state.
Only a registered peer may be called for anything other than credentials and versions.
Sourcepub const fn accepts_credentials_post(&self) -> bool
pub const fn accepts_credentials_post(&self) -> bool
Whether a credentials POST is the right method in this state.
This method MUST return a HTTP status code 405: method not allowed if the client has already been registered before.
Sourcepub const fn accepts_credentials_put_or_delete(&self) -> bool
pub const fn accepts_credentials_put_or_delete(&self) -> bool
Whether a credentials PUT or DELETE is the right method in this state.
This method MUST return a HTTP status code 405: method not allowed if the client has not been registered yet.