#webassembly #wasm

no-std wasix

Experimental WASIX API bindings for Rust

54 releases

0.11.65 Mar 7, 2023
0.11.64 Mar 7, 2023
0.11.62 Oct 13, 2022
0.11.59 Sep 22, 2022
0.11.14+wasix-snapshot-preview… May 31, 2022

#497 in WebAssembly

Download history 23/week @ 2022-12-02 52/week @ 2022-12-09 73/week @ 2022-12-16 42/week @ 2022-12-23 31/week @ 2022-12-30 26/week @ 2023-01-06 23/week @ 2023-01-13 97/week @ 2023-01-20 38/week @ 2023-01-27 299/week @ 2023-02-03 145/week @ 2023-02-10 236/week @ 2023-02-17 86/week @ 2023-02-24 80/week @ 2023-03-03 25/week @ 2023-03-10 36/week @ 2023-03-17

235 downloads per month
Used in 13 crates (via wasmer-bus)




A Bytecode Alliance project

WASI API Bindings for Rust

Crates.io version Download docs.rs docs

This crate contains API bindings for WASIX system calls in Rust, and currently reflects the wasix_v1 module. This crate is quite low-level and provides conceptually a "system call" interface. In most settings, it's better to use the Rust standard library, which has WASI support.

The wasix crate is also entirely procedurally generated from the *.witx files describing the WASI apis. While some conveniences are provided the bindings here are intentionally low-level!


First you can depend on this crate via Cargo.toml:

wasix = "0.11"

Next you can use the APIs in the root of the module like so:

fn main() {
    let stdout = 1;
    let message = "Hello, World!\n";
    let data = [wasix::Ciovec {
        buf: message.as_ptr(),
        buf_len: message.len(),
    wasix::fd_write(stdout, &data).unwrap();

Next you can use a tool like cargo wasix to compile and run your project:

To compile Rust projects to wasm using WASI, use the wasm64-wasix target, like this:

$ wasmer run wasix
   Compiling wasix v0.11.0+wasix-snapshot-preview1
   Compiling wut v0.1.0 (/code)
    Finished dev [unoptimized + debuginfo] target(s) in 0.34s
     Running `/.cargo/bin/cargo-wasix target/wasm64-wasix/debug/wut.wasm`
     Running `target/wasm64-wasix/debug/wut.wasm`
Hello, World!


The bulk of the wasix crate is generated by the witx-bindgen tool, which lives at crates/witx-bindgen and is part of the cargo workspace.

The src/lib_generated.rs file can be re-generated with the following command:

cargo run -p witx-bindgen -- crates/witx-bindgen/WASI/phases/snapshot/witx/wasix_v1.witx > src/lib_generated.rs

Note that this uses the WASIX standard repository as a submodule. If you do not have this submodule present in your source tree, run:

git submodule update --init


This project is licensed under the Apache 2.0 license with the LLVM exception. See LICENSE for more details.


Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this project by you, as defined in the Apache-2.0 license, shall be licensed as above, without any additional terms or conditions.