5#ifndef WASMTIME_MODULE_HH
6#define WASMTIME_MODULE_HH
11#include <wasmtime/helpers.hh>
31#ifdef WASMTIME_FEATURE_COMPILER
43 auto bytes = wasm.ok();
44 return compile(engine, bytes);
61 if (error !=
nullptr) {
76 if (error !=
nullptr) {
79 return std::monostate();
99 if (error !=
nullptr) {
118 const std::string &path) {
122 if (error !=
nullptr) {
129 ImportType::List imports()
const {
130 ImportType::List list;
136 ExportType::List exports()
const {
137 ExportType::List list;
142#ifdef WASMTIME_FEATURE_COMPILER
152 if (error !=
nullptr) {
155 std::vector<uint8_t> ret;
Global compilation state in Wasmtime.
Definition: engine.hh:22
Errors coming from Wasmtime.
Definition: error.hh:26
Representation of a compiled WebAssembly module.
Definition: module.hh:28
Fallible result type used for Wasmtime.
Definition: error.hh:70
Span class used when c++20 is not available.
Definition: span.hh:47
std::size_t size() const
Returns number of data that referred by Span class.
Definition: span.hh:81
iterator end() const
Returns end iterator.
Definition: span.hh:87
T * data() const
Returns pointer to data.
Definition: span.hh:78
iterator begin() const
Returns begin iterator.
Definition: span.hh:84
WASM_API_EXTERN void wasmtime_module_imports(const wasmtime_module_t *module, wasm_importtype_vec_t *out)
Same as wasm_module_imports, but for wasmtime_module_t.
WASM_API_EXTERN wasmtime_error_t * wasmtime_module_serialize(wasmtime_module_t *module, wasm_byte_vec_t *ret)
This function serializes compiled module artifacts as blob data.
WASM_API_EXTERN void wasmtime_module_exports(const wasmtime_module_t *module, wasm_exporttype_vec_t *out)
Same as wasm_module_exports, but for wasmtime_module_t.
WASM_API_EXTERN wasmtime_error_t * wasmtime_module_deserialize(wasm_engine_t *engine, const uint8_t *bytes, size_t bytes_len, wasmtime_module_t **ret)
Build a module from serialized data.
WASM_API_EXTERN wasmtime_error_t * wasmtime_module_validate(wasm_engine_t *engine, const uint8_t *wasm, size_t wasm_len)
Validate a WebAssembly binary.
WASM_API_EXTERN wasmtime_error_t * wasmtime_module_new(wasm_engine_t *engine, const uint8_t *wasm, size_t wasm_len, wasmtime_module_t **ret)
Compiles a WebAssembly binary into a wasmtime_module_t.
WASM_API_EXTERN wasmtime_error_t * wasmtime_module_deserialize_file(wasm_engine_t *engine, const char *path, wasmtime_module_t **ret)
Deserialize a module from an on-disk file.
A list of bytes.
Definition: wasm.h:102
size_t size
Length of this vector.
Definition: wasm.h:102
wasm_byte_t * data
Pointer to the base of this vector.
Definition: wasm.h:102
A compiled Wasmtime module.
void wasm_byte_vec_delete(wasm_byte_vec_t *)
Deletes a byte vector.
Result< std::vector< uint8_t > > wat2wasm(std::string_view wat)
Converts the WebAssembly text format into the WebAssembly binary format.
Definition: wat.hh:30