Skip to main content

State

Trait State 

Source
pub trait State:
    Debug
    + Clone
    + Eq
    + PartialEq
    + Hash
    + Encodable
    + Decodable
    + MaybeSend
    + MaybeSync
    + 'static {
    type ModuleContext: Context;

    // Required methods
    fn transitions(
        &self,
        context: &Self::ModuleContext,
        global_context: &DynGlobalClientContext,
    ) -> Vec<StateTransition<Self>>;
    fn operation_id(&self) -> OperationId;

    // Provided method
    fn fmt_visualization(&self, f: &mut dyn Write, indent: &str) -> Result { ... }
}
Expand description

Implementors act as state machines that can be executed

Required Associated Types§

Source

type ModuleContext: Context

Additional resources made available in this module’s state transitions

Required Methods§

Source

fn transitions( &self, context: &Self::ModuleContext, global_context: &DynGlobalClientContext, ) -> Vec<StateTransition<Self>>

All possible transitions from the current state to other states. See StateTransition for details.

Source

fn operation_id(&self) -> OperationId

Operation this state machine belongs to. See OperationId for details.

Provided Methods§

Source

fn fmt_visualization(&self, f: &mut dyn Write, indent: &str) -> Result

Human-readable visualization of this state machine for debugging.

Defaults to Debug output. Override to show only the relevant fields instead of dumping raw crypto bytes.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl State for NeverClientStateMachine

Source§

impl State for TxSubmissionStatesSM

Source§

impl<S> State for OperationState<S>
where S: State,

Wrapper for states that don’t want to carry around their operation id. S is allowed to panic when operation_id is called.