Skip to main content

behavior/
lib.rs

1//! Pure, typed actor-behavior primitives. A [`Behavior`] folds its associated
2//! event protocol into exactly [`Actions`]: sends, fresh creations, and its
3//! next behavior or termination. Higher capabilities are composed from these
4//! explicit transition parts.
5
6// The `workers!` macro emits `::behavior::…` paths; this alias lets
7// those expansions resolve inside this crate too (macro hygiene).
8extern crate self as behavior;
9
10mod actor;
11mod calculus;
12mod effects;
13mod next;
14mod stash;
15mod supervision;
16mod timing;
17mod watch;
18
19// `Machine` is a thin state-machine helper built from the core stashing primitive.
20mod compose;
21mod machine;
22mod mailbox;
23mod protocol;
24mod shutdown;
25
26pub use actor::{
27    Address, BirthMode, Births, Create, CreationKind, Delivery, MailAddr, NoBirths, Recipient,
28    Route,
29};
30pub use calculus::{
31    ActionReducer, Behavior, BehaviorActed, BehaviorFn, Effects, EventInput, FoldFn, Folded,
32    Handler, Pure, User, UserEvent, fold_events,
33};
34pub use compose::Compose;
35pub use effects::{
36    Acted, Actions, Become, Inner, Own, SendAlgebra, SendInput, SendProduct, ServiceSends,
37};
38pub use machine::{Machine, Move};
39pub use mailbox::{Transcript, run};
40pub use next::{Never, Step};
41pub use protocol::{
42    ChildEvent, ChildStopped, CreationEvent, CreationRejection, CreationResolved, ObserveChild,
43    ObserveCreation, ObservePeer, PeerEvent, PeerStopped, ReportWorkerCreationResolved,
44    ReportWorkerStopped, ScheduleAfter, ScheduleAt, ShutdownEvent, ShutdownRequested, TimeEvent,
45    TimerElapsed, TimerGeneration, TimerId, UnwatchPeer, WorkerCreationEvent,
46    WorkerCreationResolved, WorkerEvent, WorkerStopped,
47};
48pub use shutdown::{FinalizeOnShutdown, ShutdownProtocol, ShutdownReaction, StopOnShutdown};
49pub use stash::{Stash, StashRoute};
50pub use supervision::{
51    IncarnationPhase, Proxy, ProxyActions, ProxyCommand, ProxyEvent, ProxySends, RestartPolicy,
52    Strategy, SupervisionEvent, SupervisionFailure, SupervisionFailureReaction, Supervisor,
53    SupervisorActions, SupervisorSends, restart_all, restart_one, restart_rest,
54    retire_on_supervision_failure, stop_on_supervision_failure,
55};
56pub use timing::{
57    Deadline, DeadlineActions, DeadlineEvent, DeadlineReaction, DeadlineSends, ReceiveTimeout,
58    ReceiveTimeoutActions, ReceiveTimeoutError, ReceiveTimeoutEvent, ReceiveTimeoutReaction,
59    ReceiveTimeoutSends, TimedEvent,
60};
61pub use watch::{LinkReaction, Watch, WatchEvent, WatchSends, stop_on_abnormal_death};
62
63mod exit;
64
65pub use exit::{Crash, Exit, RestartDenial, SupervisionFailureReason};
66
67pub use behavior_macros::workers;