Crates.io | wasix |
lib.rs | wasix |
version | 0.12.21 |
source | src |
created_at | 2022-05-14 18:22:04.448526 |
updated_at | 2023-06-22 13:58:18.19997 |
description | WASIX API bindings for Rust |
homepage | |
repository | https://github.com/wasix-org/wasix-abi-rust |
max_upload_size | |
id | 586738 |
size | 498,720 |
WASI(X)
WASIX adds extensions on WASIX and is managed by the wasix.org community
WASI(X) API Bindings for Rust
WASI API Bindings for Rust
WASI(X) is maintained by wasix.org.
The intent of WASIX (pronounced "was-x") is to extend the WASI proposal and
complete the ABI sufficiently now to build useful and productive applications
today - it is not intended as a fork but rather to be a superset on top of WASI.
Therefore it maintains full forwards and backwards compatibility with the preview1
version of WASI and stabilizes it for the long term.
WASIX is published on crates.io
https://crates.io/crates/wasix
Below are the current extensions supported by WASIX, they are all fully tested and incorporated into supporting runtime(s):
getpid
pthreads
support (now extended from the WASI threads spec)socket
, bind
, connect
, resolve
)
chdir
) integrated with the runtimesetjmp
/ longjmp
support (used extensively in libc
) via asyncify
fork
and vfork
)exec
, wait
)pipe
, event
)resolve
)All contributions are welcome on extending WASI(X) with other extension(s). Just submit your pull request here and we will review via normal GitHub processes.
https://github.com/orgs/wasix-org/repositories
WASIX will receive long term support by this community with a guarantee of backwards compatibility on the ABI. Runtime(s) that support this ABI are assured of its stability just as standard libraries and libraries can also count on that same stability to join the dots and make the connections.
Major bug fixes and/or zero day vulnerabilities will be addressed promptly here with careful consideration for resolving issues without compromising the long-term support goal.
First you can depend on this crate via Cargo.toml
:
[dependencies]
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 wasm32-wasix
target,
like this:
$ wasmer run my-all
Compiling wasix v0.11.0
Compiling wasi 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.