beam/adapters/mod.rs
1//! Storage and network adapters for BEAM.
2//!
3//! This module contains all adapter implementations that connect the
4//! [`crate::Node`] graph engine to external systems:
5//!
6//! # Storage Adapters
7//!
8//! - [`MemoryStorage`] — in-memory `HashMap`-backed storage (default)
9//! - [`RedbStorage`] — persistent embedded storage via [`redb`] (native only)
10//!
11//! # Storage Read/Write Split
12//!
13//! Storage adapters that implement [`Actor::try_clone_storage`] are started
14//! as two actors by the Router: a read actor (receives `Get`) and a write
15//! actor (receives `Put`, `BatchPut`, `Flush`). Both share the same
16//! underlying store via `Arc`, so reads see committed writes immediately.
17//!
18//! - [`RedbStorage`] splits — the write actor's `spawn_blocking` fsync no
19//! longer blocks the read actor's concurrent `Get` queries.
20//! - [`MemoryStorage`] does not split — in-memory writes are synchronous
21//! (no fsync), so splitting provides no benefit and would break
22//! read-after-write ordering.
23//!
24//! # Network Adapters
25//!
26//! - [`OutgoingWebsocketManager`] — outgoing WebSocket client manager (native only)
27//! - [`WsServer`] — incoming WebSocket server with optional TLS (native only)
28//! - [`WsConn`] — per-connection WebSocket actor (native only)
29//! - [`Multicast`] — UDP multicast LAN discovery (native only)
30//! - [`WebRtcPeer`] — WebRTC data channel P2P connection (feature-gated)
31//!
32//! # Adapter Protocol
33//!
34//! All adapters implement the [`crate::actor::Actor`] trait and receive
35//! [`crate::message::Message`] via the actor system. Storage adapters
36//! handle `Get`, `Put`, `BatchPut`, and `Flush`. Network adapters
37//! handle `Put` and `Get` by serializing to the wire format and
38//! forwarding to remote peers.
39
40mod memory_storage;
41
42#[cfg(not(target_arch = "wasm32"))]
43mod multicast;
44
45#[cfg(feature = "persy")]
46pub mod persy_storage;
47
48#[cfg(not(target_arch = "wasm32"))]
49mod redb_storage;
50
51#[cfg(feature = "webrtc")]
52mod webrtc;
53
54#[cfg(not(target_arch = "wasm32"))]
55mod ws_client;
56
57#[cfg(not(target_arch = "wasm32"))]
58mod ws_conn;
59
60#[cfg(not(target_arch = "wasm32"))]
61mod ws_server;
62
63#[cfg(target_arch = "wasm32")]
64mod wasm_ws;
65
66#[cfg(target_arch = "wasm32")]
67mod wasm_idb;
68
69pub use memory_storage::MemoryStorage;
70
71#[cfg(not(target_arch = "wasm32"))]
72pub use multicast::Multicast;
73
74#[cfg(feature = "persy")]
75pub use persy_storage::PersyStorage;
76
77#[cfg(not(target_arch = "wasm32"))]
78pub use redb_storage::RedbStorage;
79
80#[cfg(not(target_arch = "wasm32"))]
81pub use ws_client::OutgoingWebsocketManager;
82
83#[cfg(not(target_arch = "wasm32"))]
84pub use ws_conn::WsConn;
85
86#[cfg(not(target_arch = "wasm32"))]
87pub use ws_server::{WsServer, WsServerConfig};
88
89#[cfg(target_arch = "wasm32")]
90pub use wasm_ws::WasmWsConn;
91
92#[cfg(target_arch = "wasm32")]
93pub use wasm_idb::WasmIdbStorage;
94
95#[cfg(feature = "webrtc")]
96pub use webrtc::{WebRtcPeer, WebRtcRole};