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