📄️ Set up Rust toolchain
In the following chapters, we will show how to build and compile Rust programs into WASM bytecode and then run them in WasmEdge.
📄️ Hello world
Before we start, ensure you have Rust and WasmEdge installed.
📄️ Access OS services
The WASI (WebAssembly Systems Interface) standard is designed to allow WebAssembly applications to access operating system services. The wasm32-wasi target in the Rust compiler supports WASI. This section will use an example project to show how to use Rust standard APIs to access operating system services.
🗃️ HTTP services
🗃️ Socket networking
🗃️ AI inference
🗃️ Database drivers
📄️ Dapr services
Second State launched a new WebAssembly-based SDK for the Dapr API, which provides an easy way for Rust-based microservices in WasmEdge to interact with Dapr APIs and sidecar services.
📄️ Crypto for WASI
While optimizing compilers could allow efficient implementation of cryptographic features in WebAssembly, there are several occasions where a host implementation is more desirable. WASI-crypto aims to fill those gaps by defining a standard interface as a set of APIs. Currently not support Android.
📄️ Bindgen of Rust Functions
If your Rust program has a main() function, you could compile it into WebAssembly, and run it using the wasmedge CLI tool as a standalone application. However, a far more common use case is to compile a Rust function into WebAssembly, and then call it from a host application. That is known as an embedded WASM function. The host application uses WasmEdge language SDKs (e.g., Go, Rust, C, Python (WIP) and Java (WIP)) to call those WASM functions compiled from Rust source code. In this chapter, we will cover a little about WasmEdge-bindgen, and you can find more information here
📄️ Command interface
WASI enables WebAssembly programs to call standard library functions in the host operating system. It does so through a fine-grained security model known as “capability-based security”. The WebAssembly VM owner can grant access to host system resources when the VM starts. The program cannot access resources (e.g., file folders) that are not explicitly allowed.
📄️ Server-side rendering