| Crates.io | wasi-print |
| lib.rs | wasi-print |
| version | 0.2.2 |
| created_at | 2023-02-24 06:19:18.705822+00 |
| updated_at | 2023-02-25 07:52:49.48574+00 |
| description | WASI print and panic library for WASM no_std. |
| homepage | |
| repository | https://github.com/BartMassey/wasi-print |
| max_upload_size | |
| id | 793361 |
| size | 10,311 |
Bart Massey 2023 (version 0.2.2)
This crate contains basic niceties for writing no_std
modules for WASI. wasi-print provides:
abort() function that raises a WASI exception.panic_handler that aborts after trying to print panic information.print_fd() function that prints an &str to a WASI fd.print!(), println!(), !eprint() and !eprintln().This is a full standalone Rust WASM program using
wasi_print.
#![no_std]
use wasi_print::*;
#[no_mangle]
pub extern "C" fn math_add(x: i32, y: i32) -> i32 {
eprint!("guest running math_add({}, {}) …", x, y);
let result = x + y;
eprintln!(" and returning {}", result);
result
}
print: Include printing code. This requires nightly for
a variety of reasons.panic_handler: Provide a panic handler.Figuring out how to write this was made much easier by this excellent blog post by "James [Undefined]".
This work is licensed under the "MIT License". Please see the file
LICENSE.txt in this distribution for license terms.
Thanks to the cargo-readme crate for generation of this README.