
Understand it
Rust is the source language; WebAssembly is an execution format; WASI is a family of host interfaces. They are separate layers. A module targeting wasm32-unknown-unknown does not automatically get a filesystem, sockets, or the browser DOM. A wasm32-wasip1 program expects the corresponding WASI imports, which a browser does not provide merely by supporting WebAssembly.
Crabrix supplies a local runtime and its supported host interfaces. In the browser, a worker and runtime adapter can compile or execute locally while the website serves toolchain assets. Downloading a compiler is network activity, but it is different from sending source to a backend compiler. Shared documents can use a relay without granting another participant the right to execute source on your device.
A browser DOM integration needs a JavaScript boundary or another deliberate adapter. A guest filesystem is likewise a host-provided view; its paths are not unrestricted paths on the phone. If a library assumes operating-system processes, native threads, or unsupported networking imports, having Rust source alone does not make it compatible with this target.
Local compiler profile for this lesson's small exercise: standard-library text inspection only. The exercise classifies import names according to an explicitly supplied allowlist; it does not inspect a real module or implement a security policy. Real runtime validation must parse the binary, check actual imports and limits, and preserve the host's sandbox. Keep educational models distinct from the enforcement used by a production engine.
Read the code
fn main() {
let declared = ["fd_write", "path_open"];
let allowed = ["fd_write"];
assert!(
declared
.iter()
.any(|name| !allowed.contains(name))
);
}
Targets, host imports, and local execution
Try it
For this educational model, return true exactly when every import name occurs verbatim in allowed. Empty imports pass. Do not use prefix matching. This function is not a real WASM verifier. In the Crabrix app, open the compiler lab and complete the supplied function in solution.rs. The reading question is a separate exercise.
What success looks like: The local compiler accepts the changed solution and the separate verification harness finishes all normal and boundary cases. Printing a success message alone does not complete this lab.
Check your understanding
Does browser WebAssembly support automatically supply WASI filesystem imports?
Reveal the answer
- Yes, including the user's entire disk
- No; the embedding host must supply the expected imports
- Only when the source was Rust
The host supplies imports and authority. WebAssembly support alone does not supply a WASI environment.
Go deeper
Common misconception: A Rust wasm file can call every browser and operating-system API.
The chosen target and embedding determine the available interfaces.
- Target: Identify the module's required ABI and imports.
- Host: Check which interfaces and directory grants the runtime supplies.
- Execute: Run locally only after the local user initiates execution.
Transfer challenge: Explain why serving a compiler asset, relaying an encrypted document, and executing user source are three separate operations.
Connections
- Linear Memory Boundaries: Checked offsets, lengths, and borrowed slices