Examples of WasmEdge Rust SDK

All examples have been verified on Ubuntu-20.04/22.04.

Wasm App

This example demonstrates how to create a WebAssembly application and run it as a wasm module over WasmEdge Runtime.

Wasm Library

This example demonstrates how to define a wasm library and call the APIs exported from the wasm library in WasmEdge Runtime.

This example demonstrates how to use external functions in a wasm library, and how to call such a wasm library with WasmEdge Rust SDK.

This example demonstrates how a wasm function defined in one wasm library can be imported and called by another wasm library.

Host Functions

This example demonstrates how to define a native function as a host function with #[host_function] macro, and register it into a WasmEdge Vm and run it over WasmEdge Runtime.

This example demonstrates how to define a native function as a host function with #[host_function] macro. A host context data is used in the host function.

This example demonstrates how to define a host function that takes two arguments of Rust built-in String or string slice type.

This example demonstrates how to define wasm functions, of which the arguments are of Rust built-in types instead of WebAssembly types.

Memory and Table

This example demonstrates how to manipulate linear memory.

This example demonstrates how to use WebAssembly Table and FuncRef together to invoke host functions.

AOT

This example demonstrates how to generate a AOT file with WasmEdge AOT compiler, and then load the file and run the wasm function in AOT mode.

WASI

This example demonstrates how to set environment variables and arguments via WasmEdge wasi interface.

This example demonstrates how to call a wasm function in asynchronous way. Also, it presents the usage of async-wasi interface.

This example presents how to retrieve the socket address information asynchronously.

WASI-NN

This example demonstrates how to perform an object detection task over WasmEdge Runtime.

This example demonstrates how to chat with Llama2 model driven by WasmEdge wasi-nn-ggml backend.

Plugin Development

This example demonstrates how to create a simple plugin with WasmEdge Rust SDK.

This example demonstrates how to create a simple plugin with WasmEdge Rust SDK, and run it with WasmEdge Executor.

Multi-threading

This example demonstrates how to use WasmEdge Rust SDK to create multiple threads to help us render Mandelbrot set in parallel, which is a compute-intensive workload. This example also present sharing the image memory between threads while rendering the image parallelly.

Async\await

This example demonstrates how to define a native async function as an async host function with #[async_host_function] macro, and register it into a WasmEdge Vm and run it over WasmEdge Runtime.

This example demonstrates how to define a native async function as an async host function with #[async_host_function] macro. A host context data is used in the host function.

This example demonstrates how to call a wasm function in asynchronous way.