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§
- wasm_module_ t 
- Opaque type representing a WebAssembly module.
Functions§
- wasm_module_ ⚠delete 
- Deletes a WebAssembly module.
- wasm_module_ ⚠deserialize 
- Deserializes a serialized module binary into a wasm_module_t.
- wasm_module_ ⚠exports 
- Returns an array of the exported types in the module.
- wasm_module_ ⚠imports 
- Returns an array of the imported types in the module.
- wasm_module_ ⚠new 
- A WebAssembly module contains stateless WebAssembly code that has already been compiled and can be instantiated multiple times.
- wasm_module_ ⚠serialize 
- Serializes a module into a binary representation that the
engine can later process via
wasm_module_deserialize.
- wasm_module_ ⚠validate 
- Validates a new WebAssembly module given the configuration in the store.