View Source cure_fsm_cure_api (cure v0.1.0)

Cure FSM API Wrapper

This module provides the Cure-level FSM API that matches the design in lib/std/fsm.cure. It wraps the underlying cure_fsm_runtime gen_server to provide:

  • start_fsm/1: Start an FSM instance from a module
  • fsm_cast/2: Send events asynchronously
  • fsm_advertise/2: Register a name for an FSM
  • fsm_state/1: Query current state and payload

The FSM definitions in Cure modules are compiled to:

  1. A record type for the payload
  2. A list of transitions with handler functions
  3. An initial state and initial payload

This module bridges the gap between Cure's high-level FSM syntax and the Erlang gen_server runtime.

Summary

Functions

fsm_advertise(Pid, Name)

-spec fsm_advertise(Pid :: pid(), Name :: atom()) -> ok | {error, term()}.

fsm_cast(Target, Event)

-spec fsm_cast(Target :: pid() | atom(), Event :: {atom(), list()}) -> ok.

fsm_state(Target)

-spec fsm_state(Target :: pid() | atom()) -> {ok, {atom(), term()}} | {error, term()}.

start_fsm(Module)

-spec start_fsm(Module :: atom()) -> {ok, pid()} | {error, term()}.