pub struct StateMachine { /* private fields */ }Implementations§
Source§impl StateMachine
impl StateMachine
pub fn new(config: StateConfig) -> Result<StateMachine, AgentError>
pub fn current(&self) -> String
pub fn previous(&self) -> Option<String>
pub fn current_definition(&self) -> Option<StateDefinition>
pub fn get_definition(&self, state: &str) -> Option<&StateDefinition>
pub fn get_parent_definition(&self) -> Option<StateDefinition>
Sourcepub fn current_tool_scope_snapshot(&self) -> (u64, Vec<Vec<ToolRef>>)
pub fn current_tool_scope_snapshot(&self) -> (u64, Vec<Vec<ToolRef>>)
Returns the generation and every explicit tool scope from root to current state as one authority snapshot.
Sourcepub fn generation(&self) -> u64
pub fn generation(&self) -> u64
Returns the current state-authority generation after any active mutation completes.
Sourcepub fn transition_to(&self, state: &str, reason: &str) -> Result<(), AgentError>
pub fn transition_to(&self, state: &str, reason: &str) -> Result<(), AgentError>
Applies one valid transition and advances the authority generation after all state fields are committed.
pub fn available_transitions(&self) -> Vec<Transition>
pub fn auto_transitions(&self) -> Vec<Transition>
pub fn history(&self) -> Vec<StateTransitionEvent>
pub fn increment_turn(&self)
pub fn turn_count(&self) -> u32
pub fn increment_no_transition(&self)
pub fn no_transition_count(&self) -> u32
pub fn reset_no_transition(&self)
pub fn check_fallback(&self) -> Option<String>
Sourcepub fn reset(&self)
pub fn reset(&self)
Restores the initial state and advances generation only when reset changes machine state.
Sourcepub fn snapshot(&self) -> StateMachineSnapshot
pub fn snapshot(&self) -> StateMachineSnapshot
Captures a consistent persistence snapshot after any active state mutation completes.
Sourcepub fn restore(&self, snapshot: StateMachineSnapshot) -> Result<(), AgentError>
pub fn restore(&self, snapshot: StateMachineSnapshot) -> Result<(), AgentError>
Restores a valid snapshot and advances generation only when persisted machine state differs.
pub fn config(&self) -> &StateConfig
pub fn check_timeout(&self) -> Option<String>
pub fn current_depth(&self) -> usize
pub fn is_in_sub_state(&self) -> bool
pub fn parent_state(&self) -> Option<String>
pub fn root_state(&self) -> String
Sourcepub fn is_on_cooldown(&self, target: &str, cooldown_turns: u32) -> bool
pub fn is_on_cooldown(&self, target: &str, cooldown_turns: u32) -> bool
Check if a transition target is on cooldown (was recently transitioned to).
Auto Trait Implementations§
impl !Freeze for StateMachine
impl !RefUnwindSafe for StateMachine
impl Send for StateMachine
impl Sync for StateMachine
impl Unpin for StateMachine
impl UnsafeUnpin for StateMachine
impl UnwindSafe for StateMachine
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more