Skip to main content

Crate wasmedge_sdk

Crate wasmedge_sdk 

Source
Expand description

§Overview

WasmEdge Rust SDK provides idiomatic Rust language bindings for WasmEdge

Notice: This project is still under active development and not guaranteed to have a stable API.

§Get Started

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.17.10.17.10.21.00.6.10.6.10.2.2
0.16.10.16.10.20.00.6.00.6.10.2.1
0.14.10.14.10.19.40.6.00.6.10.2.1
0.14.00.14.00.19.00.6.00.6.10.2.0
0.13.5-newapi0.13.50.18.00.5.00.6.10.2.0
0.13.20.13.50.17.50.4.40.6.10.1.0
0.13.10.13.50.17.40.4.40.6.10.1.0
0.13.00.13.50.17.30.4.40.6.10.1.0
0.12.20.13.40.17.20.4.40.6.10.1.0
0.12.10.13.40.17.10.4.40.6.10.1.0
0.12.00.13.40.17.00.4.40.6.10.1.0
0.11.20.13.30.16.20.4.30.6.10.1.0
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 will automatically search for the WasmEdge library in your system. Alternatively you can set the WASMEDGE_DIR environment variable to the path of the WasmEdge library (or the WASMEDGE_INCLUDE_DIR and WASMEDGE_LIB_DIR variables for more fine-grained control). If you want to use a local cmake build of WasmEdge you can set the WASMEDGE_BUILD_DIR instead.

WasmEdge Rust SDK will search for the WasmEdge library in the following paths in order:

  • $WASMEDGE_[INCLUDE|LIB]_DIR
  • $WASMEDGE_DIR
  • $WASMEDGE_BUILD_DIR
  • $HOME/.wasmedge
  • /usr/local
  • $HOME/.local

When the standalone feature is enabled the correct library will be downloaded during build time and the previous locations are ignored. You can specify a proxy for the download process using the WASMEDGE_STANDALONE_PROXY, WASMEDGE_STANDALONE_PROXY_USER and WASMEDGE_STANDALONE_PROXY_PASS environment variables. You can set the WASMEDGE_STANDALONE_ARCHIVE environment variable to use a local archive instead of downloading one. The following architectures are supported for automatic downloads:

oslibcarchitecturelinking type
macos-x86_64, aarch64dynamic
linuxglibcx86_64, aarch64static, dynamic
linuxmuslx86_64, aarch64static

This crate uses rust-bindgen during the build process. If you would like to use an external rust-bindgen you can set the WASMEDGE_RUST_BINDGEN_PATH environment variable to the bindgen executable path. This is particularly useful in systems like Alpine Linux (see rust-lang/rust-bindgen#2360, rust-lang/rust-bindgen#2333).

Notice: The minimum supported Rust version is 1.71.

§API Reference

§Examples

The Examples of WasmEdge RustSDK repo contains a number of examples that demonstrate how to use the WasmEdge Rust SDK.

§Contributing

Please read the contribution guidelines on how to contribute code.

§License

This project is licensed under the terms of the Apache 2.0 license.

Modules§

asyncLinux and async
config
Defines the structs used to construct configurations.
error
Defines WasmEdge error types.
plugin
Defines plugin related structs.
types
Defines the general types.
utils
Defines WasmEdge Driver and CoreVersion types
wasi

Macros§

params
Generates arguments of WasmValue types.

Structs§

Compileraot
Defines WasmEdge ahead-of-time(AOT) compiler and the relevant APIs.
ExportType
Defines the types of the exported instances.
FuncType
Struct of WasmEdge FuncType.
GlobalType
Struct of WasmEdge GlobalType.
ImportObjectBuilder
Creates a import object.
ImportType
Defines the types of the imported instances.
LogManager
Manipulates the runtime logger.
MemoryType
Struct of WasmEdge MemoryType.
Module
Defines compiled in-memory representation of an input WASM binary.
Statistics
Used to collect statistics of the WasmEdge runtime, such as the count of instructions in execution.
Store
The Store is a collection of registered modules and assists wasm modules in finding the import modules they need.
TableType
Struct of WasmEdge TableType.
Vm
A Vm defines a virtual environment for managing WebAssembly programs.

Enums§

CompilerOptimizationLevel
Defines WasmEdge AOT compiler optimization level.
CompilerOutputFormat
Defines WasmEdge AOT compiler output binary format.
ExternalInstanceType
Defines the type of external WasmEdge instances.
HostRegistration
Defines WasmEdge host module registration enum.
Mutability
Defines the mutability property of WasmEdge Global variables.
RefType
Defines WasmEdge reference types.
RunMode
Defines the execution mode of the WasmEdge runtime.
ValType
Defines WasmEdge value types.
WasmStandard
Defines the WebAssembly standard versions.

Traits§

AsInstance
The object as an module instance is required to implement this trait.
WasmVal
Defines the function converting a value of Rust type to the one of Wasm type.
WasmValType
Describes the mapping of Rust type to Wasm type.
WasmValTypeList
Describes the mapping of a tuple of Rust types to Wasm types.

Functions§

wat2wasm
Parses in-memory bytes as either the WebAssembly Text format, or a binary WebAssembly module. Parses in-memory bytes as either the WebAssembly Text format, or a binary WebAssembly module.

Type Aliases§

ImportObject
Defines an import object that contains the required import data used when instantiating a module.
Instance
Represents an instantiated module.
NeverType
This is a workaround solution to the never type in Rust. It will be replaced by ! once it is stable.
WasmEdgeResult
The WasmEdge result type.
WasmValue
WebAssembly value type.

Attribute Macros§

async_host_functionLinux and async
Declare a native async function that will be used to create an async host function instance.
host_function
Declare a native function that will be used to create a host function instance.