Skip to main content

wasm3x_sys/
lib.rs

1//! Raw FFI bindings to the [Wasm3] WebAssembly interpreter.
2//!
3//! The bindings are generated at build time with `bindgen` from the vendored
4//! Wasm3 C sources and expose the public `m3_*` C-API verbatim. Prefer the safe
5//! wrapper crate over using these bindings directly.
6//!
7//! [Wasm3]: https://github.com/wasm3/wasm3
8#![allow(non_upper_case_globals)]
9#![allow(non_camel_case_types)]
10#![allow(non_snake_case)]
11#![allow(dead_code)]
12#![allow(clippy::all)]
13
14include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
15
16#[cfg(test)]
17mod tests {
18    use super::*;
19
20    /// Smoke test: create and free an environment and a runtime.
21    #[test]
22    fn environment_and_runtime_roundtrip() {
23        unsafe {
24            let env = m3_NewEnvironment();
25            assert!(!env.is_null());
26            let runtime = m3_NewRuntime(env, 64 * 1024, core::ptr::null_mut());
27            assert!(!runtime.is_null());
28            m3_FreeRuntime(runtime);
29            m3_FreeEnvironment(env);
30        }
31    }
32}