#[non_exhaustive]pub enum MemberState {
Reserved,
Provisioned,
Active,
Cancelled,
Suspended,
Removed,
}Expand description
The state of a tenant’s membership of a node.
The text form is the lowercase name (reserved, provisioned, active,
cancelled, suspended, removed), used by Display,
FromStr and serde. Parsing is strict: any other text, including
another case, is refused. A reader that must survive a state it does not
know, such as the gate reading the directory, uses
DirectoryMemberState instead.
The transitions are:
| From | To |
|---|---|
(none), removed, cancelled | reserved (redemption; a returning key gets the next generation) |
reserved | provisioned, cancelled |
provisioned | active |
provisioned, active | suspended |
suspended | the state it remembered (resume), removed |
Three predicates name the sets of states the node acts on, so that every
component decides them in one place: holds_slot
(capacity), may_provision (repair and the
reconciler) and is_listed (the gate’s directory and
the unsigned profile read).
§Examples
use stratum_node_core::MemberState;
let state: MemberState = "suspended".parse()?;
assert_eq!(state, MemberState::Suspended);
assert_eq!(state.to_string(), "suspended");
assert!(state.holds_slot());
assert!(!state.may_provision());
assert!(state.is_listed());
assert!(!MemberState::Removed.holds_slot());
assert!("Active".parse::<MemberState>().is_err());Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Reserved
The invitation was consumed and a slot is held; the pod is not yet confirmed created.
Provisioned
The pod server created the pod.
Active
The owner stated that a read and a write to their pod worked.
Cancelled
The administrator cancelled a reserved member; no slot is held.
Suspended
The administrator stopped this member. The membership remembers
whether it was provisioned or active, holds its slot, and every
signed request by or to the member is refused.
Removed
The administrator ended this membership. No slot is held; the pod data stays on disk until it is purged.
Implementations§
Source§impl MemberState
impl MemberState
Sourcepub const ALL: [Self; 6]
pub const ALL: [Self; 6]
Every state, in declaration order.
Tests and the store iterate this list to check that a rule written elsewhere, such as an SQL predicate, agrees with the predicates here for every state.
§Examples
use stratum_node_core::MemberState;
let slot_states: Vec<&str> = MemberState::ALL
.iter()
.filter(|s| s.holds_slot())
.map(|s| s.as_str())
.collect();
assert_eq!(slot_states, ["reserved", "provisioned", "active", "suspended"]);Sourcepub fn as_str(self) -> &'static str
pub fn as_str(self) -> &'static str
Returns the lowercase name.
§Examples
use stratum_node_core::MemberState;
assert_eq!(MemberState::Removed.as_str(), "removed");Sourcepub fn holds_slot(self) -> bool
pub fn holds_slot(self) -> bool
Returns true for the states that count against the node’s tenant
capacity: reserved, provisioned, active and suspended.
This is the one definition of capacity. The store builds its SQL count from it.
§Examples
use stratum_node_core::MemberState;
assert!(MemberState::Suspended.holds_slot());
assert!(!MemberState::Cancelled.holds_slot());
assert!(!MemberState::Removed.holds_slot());Sourcepub fn may_provision(self) -> bool
pub fn may_provision(self) -> bool
Returns true for the states on which provisioning may act: the
reconciler, a recorded provisioning failure and an administrator’s
repair. Those are reserved, provisioned and active.
This is deliberately not holds_slot: a
suspended member holds a slot, but nothing may call the pod server
on its behalf, and neither may anything for a removed or
cancelled one. Callers test this before any external call.
§Examples
use stratum_node_core::MemberState;
assert!(MemberState::Reserved.may_provision());
assert!(MemberState::Active.may_provision());
assert!(!MemberState::Suspended.may_provision());
assert!(!MemberState::Removed.may_provision());Sourcepub fn is_listed(self) -> bool
pub fn is_listed(self) -> bool
Returns true for the states the controller lists in the gate’s
member directory: provisioned, active and suspended.
The same set decides whether the gate serves a key’s profile
document without a signature. A reserved, cancelled or removed
key is absent from the directory, and the gate treats it as a key
that was never a member.
§Examples
use stratum_node_core::MemberState;
assert!(MemberState::Suspended.is_listed());
assert!(!MemberState::Reserved.is_listed());
assert!(!MemberState::Removed.is_listed());