Expand description
Generic state machine infrastructure for domain state machines.
Phase 0 generic base for the state_machine.rs generator (Category C).
Every generated {Name}StateMachine used to re-define the same structural
boilerplate. This module provides:
StateMachineError— shared error type (identical across all modules)TransitionMeta<S>— required trait for Transition enumsStateMachineBehavior— trait with default impls for all mechanical methods
Generated files collapse to:
ⓘ
use backbone_core::state_machine::{
StateMachineError, StateMachineBehavior, TransitionMeta,
};
pub enum AgentState { PendingVerification, Active, Terminated }
pub enum AgentTransition { Approve, Suspend, Terminate }
impl TransitionMeta<AgentState> for AgentTransition {
fn target_state(&self) -> AgentState { ... }
fn all() -> Vec<Self> { vec![...] }
fn allowed_roles(&self) -> &'static [&'static str] { ... }
}
pub struct AgentStateMachine { current_state: AgentState }
impl StateMachineBehavior for AgentStateMachine {
type State = AgentState;
type Transition = AgentTransition;
fn current_state(&self) -> AgentState { self.current_state }
fn set_current_state(&mut self, s: AgentState) { self.current_state = s; }
fn can_transition(&self, t: AgentTransition) -> bool { /* unique table */ }
}Enums§
- State
Machine Error - Shared error type for all state machines.
Traits§
- State
Machine Behavior - Trait that provides all mechanical state machine methods as default impls.
- Transition
Meta - Required trait for Transition enums — provides the metadata that
StateMachineBehaviordefault methods need.