RFC 017 chunk 1: gen_statem primitives (no macro yet)
Runtime support layer for gen_statem, built against existing public API (channel + scheduler::spawn), sibling to gen_server. No macro: per review, build the primitives first and hand-write the Switch example to evaluate whether a statem! macro earns its place before committing to one. - src/statem.rs: Machine trait (on_start/handle), Resolution<S> with From<S>, Cx (on_unhandled), Reply<T> move-only reply handle, StatemRef (send/call), spawn + inbox loop. Real time only; Postpone + Cx timeout arming are in the type surface but not yet acted on (chunks 2-3). - examples/statem_switch.rs: the RFC Switch machine hand-written against the primitives, tagged USER vs MACRO to mark what a macro would generate. Asserts the RFC end-state (flips=1, enters=3). - tests/statem.rs: call/cast round-trip, enter-on-start/transition-not-stay, panicking-handler -> Down. Reply<T> included (the call helper needs a handle type; keeps the example true to the RFC surface) but isolated and trivially removable if we drop it.
This commit is contained in:
@@ -27,6 +27,7 @@ pub mod registry;
|
||||
pub mod pg;
|
||||
pub mod link;
|
||||
pub mod gen_server;
|
||||
pub mod statem;
|
||||
pub mod introspect;
|
||||
#[cfg(feature = "observer")]
|
||||
pub mod observer;
|
||||
@@ -57,6 +58,10 @@ pub use gen_server::{
|
||||
call, cast, shutdown, whereis_server, CallError, CallTimeoutError, CastError, GenServer,
|
||||
NamedServerBuilder, ServerBuilder, ServerCtx, ServerName, ServerRef, TimerHandle, Watcher,
|
||||
};
|
||||
pub use statem::{
|
||||
CallError as StatemCallError, Cx, Machine, Reply, Resolution, SendError as StatemSendError,
|
||||
StatemRef,
|
||||
};
|
||||
pub use introspect::{
|
||||
actor_info, snapshot, tree, tree_from, ActorInfo, ActorState, RuntimeSnapshot, RuntimeTree,
|
||||
TreeNode, SNAPSHOT_FORMAT_VERSION,
|
||||
|
||||
Reference in New Issue
Block a user