Skip to main content

graphrt_wasm/
lib.rs

1//! # graphrt-wasm
2//!
3//! Sandboxed WebAssembly plugins that add node kinds to a graphrt
4//! [`Registry`](graphrt_core::Registry).
5//!
6//! - **Portable:** one `.wasm` file runs on every OS and CPU the host runs on.
7//! - **Sandboxed:** guests run in the pure-Rust wasmi interpreter with a fuel
8//!   (CPU) budget, a memory cap, bounded I/O buffers and no system access. The
9//!   only imports are `graphrt::log`, `graphrt::chunk` and `graphrt::progress`.
10//! - **Stateless:** every run gets a fresh instance.
11//! - **Small:** wasmi adds well under a megabyte to a release binary.
12//!
13//! ```no_run
14//! use graphrt_core::Registry;
15//! use graphrt_wasm::{WasmLimits, WasmPlugin};
16//!
17//! # fn main() -> Result<(), graphrt_wasm::WasmError> {
18//! let plugin = WasmPlugin::load_file("plugins/text_tools.wasm", WasmLimits::default())?;
19//! let mut registry = Registry::with_builtins();
20//! plugin.register(&mut registry)?; // adds e.g. `slugify` and `word-count`
21//! # Ok(()) }
22//! ```
23//!
24//! The guest ABI is documented in [`abi`] and in `docs/wasm-plugins.md`.
25
26pub mod abi;
27mod error;
28mod host;
29mod limits;
30mod plugin;
31pub mod resolve;
32
33pub use error::WasmError;
34pub use host::LogLine;
35pub use limits::WasmLimits;
36pub use plugin::WasmPlugin;