5#ifndef WASMTIME_MODULE_HH 
    6#define WASMTIME_MODULE_HH 
   36  std::unique_ptr<wasmtime_module_t, deleter> ptr;
 
   54#ifdef WASMTIME_FEATURE_COMPILER 
   66    auto bytes = wasm.ok();
 
   67    return compile(engine, bytes);
 
   84    if (error != 
nullptr) {
 
   96  static Result<std::monostate> validate(Engine &engine, Span<uint8_t> wasm) {
 
   99    if (error != 
nullptr) {
 
  102    return std::monostate();
 
  122    if (error != 
nullptr) {
 
  141                                         const std::string &path) {
 
  145    if (error != 
nullptr) {
 
  165#ifdef WASMTIME_FEATURE_COMPILER 
  175    if (error != 
nullptr) {
 
  178    std::vector<uint8_t> ret;
 
  180    Span<uint8_t> raw(
reinterpret_cast<uint8_t *
>(bytes.
data), bytes.
size);
 
  181    ret.assign(raw.begin(), raw.end());
 
Global compilation state in Wasmtime.
Definition: engine.hh:21
 
Errors coming from Wasmtime.
Definition: error.hh:25
 
An owned list of ExportType instances.
Definition: export.hh:41
 
An owned list of ImportType instances.
Definition: import.hh:46
 
A WebAssembly instance.
Definition: instance.hh:31
 
Helper class for linking modules together with name-based resolution.
Definition: linker.hh:25
 
Representation of a compiled WebAssembly module.
Definition: module.hh:27
 
Module & operator=(Module &&other)=default
Moves resources from another module into this one.
 
ImportType::List imports() const
Returns the list of types imported by this module.
Definition: module.hh:152
 
const wasmtime_module_t * capi() const
Returns the underlying C API pointer.
Definition: module.hh:188
 
Module(Module &&other)=default
Moves resources from another module into this one.
 
static Result< Module > deserialize_file(Engine &engine, const std::string &path)
Deserializes a module from an on-disk file.
Definition: module.hh:140
 
ExportType::List exports() const
Returns the list of types exported by this module.
Definition: module.hh:159
 
static Result< Module > deserialize(Engine &engine, Span< uint8_t > wasm)
Deserializes a previous list of bytes created with serialize.
Definition: module.hh:118
 
Module(const Module &other)
Copies another module into this one.
Definition: module.hh:42
 
Module & operator=(const Module &other)
Copies another module into this one.
Definition: module.hh:44
 
wasmtime_module_t * capi()
Returns the underlying C API pointer.
Definition: module.hh:191
 
Fallible result type used for Wasmtime.
Definition: error.hh:82
 
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
 
T * data() const
Returns pointer to data.
Definition: span.hh:78
 
Owner of all WebAssembly objects.
Definition: store.hh:41
 
WASM_API_EXTERN void wasmtime_module_delete(wasmtime_module_t *m)
Deletes a module.
 
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_module_t * wasmtime_module_clone(wasmtime_module_t *m)
Creates a shallow clone of the specified module, increasing the internal reference count.
 
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