beamr 0.19.1

A Rust runtime with the BEAM's execution model, targeting Gleam
Documentation
//! Beamr — a Rust runtime with the BEAM's execution model.
//!
//! Loads `.beam` bytecode produced by the Gleam toolchain (via `erlc`)
//! and executes it with preemptive scheduling, per-process isolation,
//! supervision primitives, and a native function interface.
#![cfg_attr(all(not(feature = "std"), not(target_arch = "wasm32")), no_std)]

#[cfg(any(not(feature = "std"), target_arch = "wasm32"))]
extern crate alloc;

// AR-1 R10: the accumulator-rooting hunt's control fixtures. Ships nothing —
// every item inside is `#[cfg(test)]`. It must stay under `crates/` and must
// NOT be renamed to anything ending `_tests.rs`, or the hunt stops walking it
// and all five per-class controls silently disappear. See the module docs.
mod ar1_shape_control;
// AR-1 row 1: the ordering detector's control fixtures — one committed site
// the detector must FLAG (rooting after the first collecting call) and one it
// must CLEAR. Same residency rules as `ar1_shape_control` above.
mod ar1_ordering_control;
pub mod atom;
pub mod capability;
pub mod constant_pool;
#[cfg(feature = "net")]
pub mod distribution;
pub mod error;
pub mod etf;
pub mod ets;
pub mod gc;
#[cfg(feature = "threads")]
pub mod hook;
pub mod interpreter;
#[cfg(feature = "threads")]
#[path = "io/mod.rs"]
pub mod io;
// The sink seam (`IoSink`/`NullSink`/`IoStream`) is deliberately OUTSIDE the
// `threads` gate: the cooperative wasm closure routes `io`-family output
// through it (WPORT-5 R2). The `io` module re-exports these names so threaded
// import paths stay unchanged.
pub mod io_sink;
#[cfg(feature = "jit")]
pub mod jit;
pub mod loader;
pub mod mailbox;
pub mod module;
pub mod namespace;
pub mod native;
pub mod process;
// The replay driver is a passive, in-memory event-log consumer (no threads, no
// tokio); it is reused by the cooperative runtime for deterministic delivery.
// Only its on-disk log format (`replay::file`) needs net/fs and stays gated.
//
// ⛔ UNGATED ON PURPOSE (B-144 R1). This module names NO optional dependency --
// `replay::file`'s zstd is already gated separately at replay/mod.rs. The old
// `any(threads, cooperative)` gate was not required by any dependency, and it
// made `crate::replay` vanish under `--no-default-features` while 7 sites in
// ungated modules still named it. Re-gating it re-breaks that build.
pub mod replay;
pub mod scheduler;
pub mod supervision;
#[cfg(feature = "telemetry")]
pub mod telemetry;
pub mod term;
// The passive timer wheel is polled (no thread, no tokio::sleep), so it is
// usable by the cooperative single-threaded runtime as well as the threaded one.
//
// ⛔ UNGATED ON PURPOSE (B-144 R1). `timer.rs` imports only std, `web_time` and
// `crate::term` -- no optional dependency at all. Same reasoning as `replay`
// above: the gate bought nothing and cost 12 of R1's 20 errors.
pub mod timer;

// Ergonomic native-actor surface (NATIVE-003), re-exported at the crate root so
// downstream crates depend only on `beamr::` — not on scheduler internals.
// The platform-neutral trait/type surface is available in both the threaded
// native runtime and the cooperative (wasm) runtime so haematite/liminal import
// `beamr::Actor` etc. unchanged on both targets.
#[cfg(any(feature = "threads", feature = "cooperative"))]
pub use native::actor::{Actor, ActorContext, ActorError, ActorMessage};
// The external-driver request/reply handles (`ActorRef`/`SenderHandle`) and
// `spawn_actor` own the threaded `Scheduler` and block on a channel, so they are
// threaded-only.
#[cfg(feature = "threads")]
pub use native::actor::{ActorRef, SenderHandle, spawn_actor};
// The cooperative actor surface (WR-6): `spawn_actor_cooperative` +
// `CoopActorRef`/`CoopSenderHandle` bound to the single-threaded `WasmScheduler`,
// with a non-blocking, host-pumpable `call_async` returning a `CallFuture`. Built
// wherever the `WasmScheduler` exists (the wasm `cooperative` build, and the
// `threads` build so the native test gate covers it).
#[cfg(any(feature = "threads", feature = "cooperative"))]
pub use native::actor::{CallFuture, CoopActorRef, CoopSenderHandle, spawn_actor_cooperative};
// The dynamic, term-carrying actor (WR-8): an `Actor` whose `Call`/`Reply`/`Cast`
// are opaque term graphs, so an untyped host (`beamr-wasm`) can spawn one and
// drive it over the cooperative `call_async`/`CallFuture` surface above.
#[cfg(any(feature = "threads", feature = "cooperative"))]
pub use native::actor::{DynActor, ReplyFn, WireTerm};
#[cfg(any(feature = "threads", feature = "cooperative"))]
pub use native::native_process::{NativeContext, NativeHandler, NativeOutcome};