#![allow(unused_imports)]
extern crate self as statum;
pub use statum_core::__private;
pub use statum_core::TransitionInventory;
pub use statum_core::{
CanTransitionMap, CanTransitionTo, CanTransitionWith, DataState, Error, MachineDescriptor,
MachineGraph, MachineIntrospection, MachineStateIdentity, RebuildAttempt, RebuildReport, StateDescriptor, StateMarker,
TransitionDescriptor, UnitState,
};
use statum_macros::{machine, state, validators};
#[state]
enum TaskState {
Draft,
Done,
}
#[machine]
struct TaskMachine<TaskState> {
name: String,
}
struct DbRow {
status: &'static str,
}
#[validators(TaskMachine)]
impl DbRow {
fn is_draft(&self) -> Result<(), statum_core::Error> {
let _ = name;
if self.status == "draft" {
Ok(())
} else {
Err(statum_core::Error::InvalidState)
}
}
fn is_archived(&self) -> Result<(), statum_core::Error> {
let _ = name;
if self.status == "archived" {
Ok(())
} else {
Err(statum_core::Error::InvalidState)
}
}
}