zwasm-sdk 0.1.0

A safe and ergonomic Rust binding for the zwasm WebAssembly runtime, supporting Wasm 3.0, WASI, and host function imports.
/* ------------------------------------------------------------------ */
/* Wasm test modules (hand-coded binary)                              */
/* ------------------------------------------------------------------ */

/* Minimal valid: magic + version only */
pub(crate) const MINIMAL_WASM: &[u8] = &[0x00, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00];

/* (func (export "f") (result i32) (i32.const 42)) */
pub(crate) const RETURN42_WASM: &[u8] = &[
    0x00, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00, 0x01, 0x05, 0x01, 0x60, 0x00, 0x01, 0x7f, 0x03,
    0x02, 0x01, 0x00, 0x07, 0x05, 0x01, 0x01, 0x66, 0x00, 0x00, 0x0a, 0x06, 0x01, 0x04, 0x00, 0x41,
    0x2a, 0x0b,
];

/* (func (export "add") (param i32 i32) (result i32) (i32.add (local.get 0) (local.get 1))) */
pub(crate) const ADD_WASM: &[u8] = &[
    0x00, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00, 0x01, 0x07, 0x01, 0x60, 0x02, 0x7f, 0x7f, 0x01,
    0x7f, 0x03, 0x02, 0x01, 0x00, 0x07, 0x07, 0x01, 0x03, 0x61, 0x64, 0x64, 0x00, 0x00, 0x0a, 0x09,
    0x01, 0x07, 0x00, 0x20, 0x00, 0x20, 0x01, 0x6a, 0x0b,
];

/* (memory (export "m") 1) + (func (export "f") i32.store(0, 42)) */
pub(crate) const MEMORY_WASM: &[u8] = &[
    0x00, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00, 0x01, 0x04, 0x01, 0x60, 0x00,
    0x00, /* type: () -> () */
    0x03, 0x02, 0x01, 0x00, /* func section */
    0x05, 0x03, 0x01, 0x00, 0x01, /* memory: min=0, max=1 */
    0x07, 0x09, 0x02, /* export section: 2 exports */
    0x01, 0x6d, 0x02, 0x00, /* "m" = mem 0 */
    0x01, 0x66, 0x00, 0x00, /* "f" = func 0 */
    0x0a, 0x0b, 0x01, 0x09, 0x00, 0x41, 0x00, 0x41, /* code */
    0x2a, 0x36, 0x02, 0x00, 0x0b,
];

/* Module: imports "env" "add" (i32,i32)->i32, exports "call_add" */
pub(crate) const IMPORT_WASM: &[u8] = &[
    0x00, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00, 0x01, 0x07, 0x01, 0x60, 0x02, 0x7f, 0x7f, 0x01,
    0x7f, 0x02, 0x0b, 0x01, 0x03, 0x65, 0x6e, 0x76, 0x03, 0x61, 0x64, 0x64, 0x00, 0x00, 0x03, 0x02,
    0x01, 0x00, 0x07, 0x0c, 0x01, 0x08, 0x63, 0x61, 0x6c, 0x6c, 0x5f, 0x61, 0x64, 0x64, 0x00, 0x01,
    0x0a, 0x0a, 0x01, 0x08, 0x00, 0x41, 0x03, 0x41, 0x04, 0x10, 0x00, 0x0b,
];