Skip to main content

beam/
lib.rs

1#![allow(rustdoc::broken_intra_doc_links, rustdoc::private_intra_doc_links)]
2
3// Global allocator — mimalloc.
4//
5// mimalloc is a compact general-purpose allocator by Microsoft with excellent
6// performance characteristics. It uses per-thread heap segments with deferred
7// freeing, reducing contention and fragmentation compared to glibc's malloc.
8//
9// Enabled by default on native targets via the `mimalloc` feature. Disabled on
10// WASM (no system allocator to replace) and when the feature is turned off.
11//
12// To use the system allocator instead: `cargo build --no-default-features --features native`
13#[cfg(all(feature = "mimalloc", not(target_arch = "wasm32")))]
14#[global_allocator]
15static GLOBAL: mimalloc::MiMalloc = mimalloc::MiMalloc;
16
17pub mod ack;
18pub mod actor;
19pub mod adapters;
20/// Thread-safe bump arena allocator (native only — uses `std::sync::Mutex`).
21#[cfg(not(target_arch = "wasm32"))]
22pub mod arena;
23mod dup;
24pub mod mailbox;
25#[doc(hidden)]
26pub mod message; // pub for benchmarking
27pub mod metrics;
28mod tokio_spawn;
29mod tokio_time;
30
31#[cfg(not(target_arch = "wasm32"))]
32pub mod migration;
33
34mod node;
35mod router;
36#[cfg(feature = "webrtc")]
37mod stun;
38pub mod types;
39pub mod utils; // pub for benchmarking
40pub use dup::Dup;
41pub mod sea;
42pub use node::{Config, Node};
43pub use types::Value;
44
45#[cfg(target_arch = "wasm32")]
46pub mod wasm;
47
48#[cfg(all(target_arch = "wasm32", test))]
49mod wasm_tests;
50// Include README.md as doctests — all ```rust code blocks in README are
51// compiled and run when `cargo test --doc` (or `cargo test`) is executed.
52// The struct only exists during doctest collection, so it's invisible in
53// the public API and has zero runtime cost.
54#[cfg(not(target_arch = "wasm32"))]
55#[doc = include_str!("../README.md")]
56#[cfg(doctest)]
57pub struct ReadmeDoctests;