tiny-async-runtime is a minimal, WASI-compatible async runtime designed to run on WebAssembly with WASI Preview 3.
It provides:
- Single-threaded cooperative task scheduling
- Futures spawning and cancellation
- Timeout support
- Socket I/O integration
This runtime is inspired by mio but is purpose-built for WASI environments.
This crate is meant to be validated in a WASI Preview 3 host.
Here is a minimal example using block_on and spawn, exported as this crate's async run via #[tiny_wasm_runtime::main] on fn main:
use tiny_wasm_runtime::{Timer, WasmRuntimeAsyncEngine};
#[tiny_wasm_runtime::main]
async fn main() {
let handle = WasmRuntimeAsyncEngine::spawn(async {
Timer::sleep(std::time::Duration::from_secs(1)).await;
42
});
let result = handle.await;
println!("Background task returned: {result}");
}