pub struct FsmEngine { /* private fields */ }Expand description
Finite state machine engine.
Implementations§
Source§impl FsmEngine
impl FsmEngine
pub fn new() -> Self
Sourcepub fn create_fsm(
&mut self,
name: &str,
states: Vec<State>,
transitions: Vec<Transition>,
initial_state: &str,
) -> WorkflowResult<String>
pub fn create_fsm( &mut self, name: &str, states: Vec<State>, transitions: Vec<Transition>, initial_state: &str, ) -> WorkflowResult<String>
Create a new state machine.
Sourcepub fn transition(
&mut self,
fsm_id: &str,
event: &str,
) -> WorkflowResult<String>
pub fn transition( &mut self, fsm_id: &str, event: &str, ) -> WorkflowResult<String>
Attempt a state transition.
Sourcepub fn current_state(&self, fsm_id: &str) -> WorkflowResult<&str>
pub fn current_state(&self, fsm_id: &str) -> WorkflowResult<&str>
Get current state.
Sourcepub fn valid_next(&self, fsm_id: &str) -> WorkflowResult<Vec<&Transition>>
pub fn valid_next(&self, fsm_id: &str) -> WorkflowResult<Vec<&Transition>>
Get valid next transitions.
Sourcepub fn get_history(&self, fsm_id: &str) -> WorkflowResult<&[TransitionRecord]>
pub fn get_history(&self, fsm_id: &str) -> WorkflowResult<&[TransitionRecord]>
Get transition history.
Sourcepub fn get_fsm(&self, fsm_id: &str) -> WorkflowResult<&StateMachine>
pub fn get_fsm(&self, fsm_id: &str) -> WorkflowResult<&StateMachine>
Get a state machine.
Sourcepub fn diagram(&self, fsm_id: &str) -> WorkflowResult<String>
pub fn diagram(&self, fsm_id: &str) -> WorkflowResult<String>
Generate a Mermaid state diagram.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for FsmEngine
impl RefUnwindSafe for FsmEngine
impl Send for FsmEngine
impl Sync for FsmEngine
impl Unpin for FsmEngine
impl UnsafeUnpin for FsmEngine
impl UnwindSafe for FsmEngine
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more