use std::fmt::Debug;
use thiserror::Error;
#[derive(Debug, Clone, Copy, Eq, PartialEq, Error)]
pub enum StateMachineError<S, E>
where
S: Debug,
E: Debug,
{
#[error("unknown state: {state:?}")]
UnknownState {
state: S,
},
#[error("unknown transition: {source_state:?} --{event:?}--> ?")]
UnknownTransition {
source_state: S,
event: E,
},
#[error("CAS transition failed after {attempts} attempt(s)")]
CasConflict {
attempts: u32,
},
}
pub type StateMachineResult<S, E> = Result<S, StateMachineError<S, E>>;