Module wasmer_c_api::wasm_c_api::module

source ·
Expand description

A WebAssembly module contains stateless WebAssembly code that has already been compiled and can be instantiated multiple times.

Entry points: A WebAssembly module is created with wasm_module_new and freed with wasm_module_delete.

§Example

int main() {
    // Create the engine and the store.
    wasm_engine_t* engine = wasm_engine_new();
    wasm_store_t* store = wasm_store_new(engine);

    // Create a WebAssembly module from a WAT definition.
    wasm_byte_vec_t wat;
    wasmer_byte_vec_new_from_string(&wat, "(module)");
    wasm_byte_vec_t wasm;
    wat2wasm(&wat, &wasm);
    
    // Create the module.
    wasm_module_t* module = wasm_module_new(store, &wasm);

    // It works!
    assert(module);
    
    // Free everything.
    wasm_byte_vec_delete(&wasm);
    wasm_byte_vec_delete(&wat);
    wasm_module_delete(module);
    wasm_store_delete(store);
    wasm_engine_delete(engine);

    return 0;
}

cbindgen:ignore

Structs§

Functions§