struct FSM::State

Overview

The runtime snapshot an interpreter returns.

State reports the outcome of one transaction, not the condition of an interpreter. By the time a snapshot exists the step is over, so there is no "running": #id is the state the machine is in, #status says whether the transaction committed, and #error holds the exception on a failed step.

Construction must maintain the invariant that Failed carries an exception and Success does not. The types do not enforce it.

State is the immutable value read constantly in consumer code, so it holds the short name; the definition carries the longer StateDefinition. Nothing in a snapshot points back into the machine definition, so it is safe to return, compare, and cache.

Defined in:

fsm/state.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(id : String, status : Status, error : Exception | Nil = nil) #

[View source]

Instance Method Detail

def error : Exception | Nil #

[View source]
def id : String #

[View source]
def status : Status #

[View source]