Skip to main content

WasmEdge Rust SDK

Overview

WasmEdge Rust SDK consists of five crates:

  • wasmedge-sdk crate defines a group of safe, ergonomic high-level APIs developers use to build up their own business applications.

  • wasmedge-sys crate is a wrapper of WasmEdge C-API and provides safe counterparts. It is not recommended to use it directly by application developers. wasmedge-sys, wasmedge-types, and wasmedge-macro constitute the low-level layer of WasmEdge Rust SDK.

  • wasmedge-types crate defines the data structures commonly used in wasmedge-sdk and wasmedge-sys.

  • wasmedge-macro crate defines the macros that are commonly used in wasmedge-sdk and wasmedge-sys to declare host functions.

  • async-wasi crate provides the asynchronous WASI APIs.

Usage

  • Deploy WasmEdge library in your local environment.

    Since this crate depends on the WasmEdge C API, it needs to be installed in your system first. Please refer to WasmEdge Installation and Uninstallation to install the WasmEdge library. The versioning table below shows the version of the WasmEdge library required by each version of the wasmedge-sdk crate.

    wasmedge-sdkWasmEdge libwasmedge-syswasmedge-typeswasmedge-macroasync-wasi
    0.11.00.13.30.16.00.4.30.6.00.0.3
    0.10.10.13.30.15.10.4.20.5.00.0.2
    0.10.00.13.20.15.00.4.20.5.00.0.2
    0.9.00.13.10.14.00.4.20.4.00.0.1
    0.9.00.13.00.14.00.4.20.4.00.0.1
    0.8.10.12.10.13.10.4.10.3.0-
    0.8.00.12.00.13.00.4.10.3.0-
    0.7.10.11.20.12.20.3.10.3.0-
    0.7.00.11.20.120.3.10.3.0-
    0.6.00.11.20.110.3.00.2.0-
    0.5.00.11.10.100.3.00.1.0-
    0.4.00.11.00.90.2.1--
    0.3.00.10.10.80.2--
    0.1.00.10.00.70.1--

    WasmEdge Rust SDK can automatically search the following paths for the WasmEdge library:

    • /usr/local (Linux/macOS)

    • $HOME/.wasmedge (Linux/macOS)

      Note that if you have installed the WasmEdge library in a different path, you can set the WASMEDGE_INCLUDE_DIR and WASMEDGE_LIB_DIR environment variables to the path of the WasmEdge library.

  • Add wasmedge-sdk crate to your Cargo.toml file. Note that, according to the versioning table, the version of wasmedge-sdk matching WasmEdge v0.13.3 is 0.11.0.

    wasmedge-sdk = "0.11.0"

Notice: The minimum supported Rust version is 1.68.

Examples

wasmedge-rustsdk-examples provides a set of examples to demonstrate how to use wasmedge-sdk to, for example, create host functions, create WebAssembly libraries, create plug-ins, etc.