abi-adapter
English | 简体中文
Generate wasm interfaces for ordinary Rust functions. abi! converts arguments
according to a declaration, calls the target, and converts its result.
No third-party dependencies; supports no_std. Requires Rust 1.85+.
Quick start
Add the crate to your project:
cargo add abi-adapter
To use unreleased changes from main, depend on the Git repository instead:
cargo add abi-adapter --git https://github.com/vhexl/abi-adapter
use abi;
abi!
host generates a regular Rust function; guest("double.v1") generates a wasm export.
Each bracketed group maps to one target argument. Slots are Rust u32 values
and wasm i32 values; wrappers directly return zero or one slot.
Custom types use FromSlots<N> and IntoSlots<N>.
For a complete wasm example, see examples/guest.rs.
Users define runtime registration, memory protocols, and error codes. Panics from conversions and target functions are not caught; guest exports trap.
Documentation
The following guides are in Chinese:
- Usage guide: custom conversions,
ctx, wasm exports, and common problems. - Buffer example: multi-slot results and memory conventions.
- Architecture: modules, execution flow, and design decisions.
- Development guide: checks, API documentation, releases, and maintenance.
License
MIT or Apache-2.0, at your option.