|
Wasmtime
|
#include <wasm.h>#include <wasmtime/component/component.h>#include <wasmtime/component/instance.h>#include <wasmtime/component/types/func.h>#include <wasmtime/conf.h>#include <wasmtime/error.h>#include <wasmtime/module.h>#include <wasmtime/store.h>Go to the source code of this file.
Typedefs | |
| typedef struct wasmtime_component_linker_t | wasmtime_component_linker_t |
| A type used to instantiate a wasmtime_component_t. | |
| typedef struct wasmtime_component_linker_instance_t | wasmtime_component_linker_instance_t |
| Structure representing an "instance" being defined within a linker. | |
| typedef wasmtime_error_t *(* | wasmtime_component_func_callback_t) (void *, wasmtime_context_t *, const wasmtime_component_func_type_t *, wasmtime_component_val_t *, size_t, wasmtime_component_val_t *, size_t) |
| Type of the callback used in wasmtime_component_linker_instance_add_func. | |
| typedef wasmtime_error_t *(* | wasmtime_component_resource_destructor_t) (void *, wasmtime_context_t *, uint32_t) |
Functions | |
| WASM_API_EXTERN wasmtime_component_linker_t * | wasmtime_component_linker_new (const wasm_engine_t *engine) |
| Creates a new wasmtime_component_linker_t for the specified engine. More... | |
| WASM_API_EXTERN void | wasmtime_component_linker_allow_shadowing (wasmtime_component_linker_t *linker, bool allow) |
| Configures whether this linker allows later definitions to shadow previous definitions. More... | |
| WASM_API_EXTERN wasmtime_component_linker_instance_t * | wasmtime_component_linker_root (wasmtime_component_linker_t *linker) |
| Returns the "root instance" of this linker, used to define names into the root namespace. More... | |
| WASM_API_EXTERN wasmtime_error_t * | wasmtime_component_linker_instantiate (const wasmtime_component_linker_t *linker, wasmtime_context_t *context, const wasmtime_component_t *component, wasmtime_component_instance_t *instance_out) |
| Instantiates a component instance in a given wasmtime_context_t. More... | |
| WASM_API_EXTERN wasmtime_error_t * | wasmtime_component_linker_define_unknown_imports_as_traps (wasmtime_component_linker_t *linker, const wasmtime_component_t *component) |
Defines all unknown imports of component as trapping functions. | |
| WASM_API_EXTERN void | wasmtime_component_linker_delete (wasmtime_component_linker_t *linker) |
| Deletes a wasmtime_component_linker_t created by wasmtime_component_linker_new. More... | |
| WASM_API_EXTERN wasmtime_error_t * | wasmtime_component_linker_instance_add_instance (wasmtime_component_linker_instance_t *linker_instance, const char *name, size_t name_len, wasmtime_component_linker_instance_t **linker_instance_out) |
| Defines a nested instance within this instance. More... | |
| WASM_API_EXTERN wasmtime_error_t * | wasmtime_component_linker_instance_add_module (wasmtime_component_linker_instance_t *linker_instance, const char *name, size_t name_len, const wasmtime_module_t *module) |
| Defines a wasmtime_module_t within this instance. More... | |
| WASM_API_EXTERN wasmtime_error_t * | wasmtime_component_linker_instance_add_func (wasmtime_component_linker_instance_t *linker_instance, const char *name, size_t name_len, wasmtime_component_func_callback_t callback, void *data, void(*finalizer)(void *)) |
| Define a function within this instance. More... | |
| WASM_API_EXTERN wasmtime_error_t * | wasmtime_component_linker_add_wasip2 (wasmtime_component_linker_t *linker) |
Add all WASI interfaces into the linker provided. | |
| WASM_API_EXTERN wasmtime_error_t * | wasmtime_component_linker_instance_add_resource (wasmtime_component_linker_instance_t *linker_instance, const char *name, size_t name_len, const wasmtime_component_resource_type_t *resource, wasmtime_component_resource_destructor_t destructor, void *data, void(*finalizer)(void *)) |
| Defines a new resource type within this instance. More... | |
| WASM_API_EXTERN void | wasmtime_component_linker_instance_delete (wasmtime_component_linker_instance_t *linker_instance) |
| Deletes a wasmtime_component_linker_instance_t. More... | |
| typedef wasmtime_error_t *(* wasmtime_component_resource_destructor_t) (void *, wasmtime_context_t *, uint32_t) |
Type of the callback used in wasmtime_component_linker_instance_add_resource
| WASM_API_EXTERN void wasmtime_component_linker_allow_shadowing | ( | wasmtime_component_linker_t * | linker, |
| bool | allow | ||
| ) |
Configures whether this linker allows later definitions to shadow previous definitions.
By default this setting is false.
| WASM_API_EXTERN void wasmtime_component_linker_delete | ( | wasmtime_component_linker_t * | linker | ) |
Deletes a wasmtime_component_linker_t created by wasmtime_component_linker_new.
| linker | the wasmtime_component_linker_t to delete |
| WASM_API_EXTERN wasmtime_error_t * wasmtime_component_linker_instance_add_func | ( | wasmtime_component_linker_instance_t * | linker_instance, |
| const char * | name, | ||
| size_t | name_len, | ||
| wasmtime_component_func_callback_t | callback, | ||
| void * | data, | ||
| void(*)(void *) | finalizer | ||
| ) |
Define a function within this instance.
| linker_instance | the instance to define the function in |
| name | the module name |
| name_len | length of name in bytes |
| callback | the callback when this function gets called |
| data | host-specific data passed to the callback invocation, can be NULL |
| finalizer | optional finalizer for data, can be NULL |
NULL, otherwise an error | WASM_API_EXTERN wasmtime_error_t * wasmtime_component_linker_instance_add_instance | ( | wasmtime_component_linker_instance_t * | linker_instance, |
| const char * | name, | ||
| size_t | name_len, | ||
| wasmtime_component_linker_instance_t ** | linker_instance_out | ||
| ) |
Defines a nested instance within this instance.
This can be used to describe arbitrarily nested levels of instances within a linker to satisfy nested instance exports of components.
linker_instance. The linker_instance MUST not be accessed by anything until the returned wasmtime_component_linker_instance_t in linker_instance_out is destroyed by wasmtime_component_linker_instance_delete.| linker_instance | the linker instance from which the new one is created |
| name | new instance name |
| name_len | length of name in bytes |
| linker_instance_out | on success, the new wasmtime_component_linker_instance_t |
NULL, otherwise an error | WASM_API_EXTERN wasmtime_error_t * wasmtime_component_linker_instance_add_module | ( | wasmtime_component_linker_instance_t * | linker_instance, |
| const char * | name, | ||
| size_t | name_len, | ||
| const wasmtime_module_t * | module | ||
| ) |
Defines a wasmtime_module_t within this instance.
This can be used to provide a core wasm wasmtime_module_t as an import to a component. The wasmtime_module_t provided is saved within the linker for the specified name in this instance.
| linker_instance | the instance to define the module in |
| name | the module name |
| name_len | length of name in bytes |
| module | the module |
NULL, otherwise an error | WASM_API_EXTERN wasmtime_error_t * wasmtime_component_linker_instance_add_resource | ( | wasmtime_component_linker_instance_t * | linker_instance, |
| const char * | name, | ||
| size_t | name_len, | ||
| const wasmtime_component_resource_type_t * | resource, | ||
| wasmtime_component_resource_destructor_t | destructor, | ||
| void * | data, | ||
| void(*)(void *) | finalizer | ||
| ) |
Defines a new resource type within this instance.
This can be used to define a new resource type that the guest will be able to import. Here the resource is a type, often a host-defined type, which can be used to distinguish and definie different types of resources. A destruction callback is also specified via destructor which has private data data along with an optional finalizer for the data too.
NULL, otherwise an error | WASM_API_EXTERN void wasmtime_component_linker_instance_delete | ( | wasmtime_component_linker_instance_t * | linker_instance | ) |
Deletes a wasmtime_component_linker_instance_t.
| linker_instance | the wasmtime_component_linker_instance_t to delete |
| WASM_API_EXTERN wasmtime_error_t * wasmtime_component_linker_instantiate | ( | const wasmtime_component_linker_t * | linker, |
| wasmtime_context_t * | context, | ||
| const wasmtime_component_t * | component, | ||
| wasmtime_component_instance_t * | instance_out | ||
| ) |
Instantiates a component instance in a given wasmtime_context_t.
| linker | a wasmtime_component_linker_t that will help provide host functions |
| context | the wasmtime_context_t in which the instance should be created |
| component | the wasmtime_component_t to instantiate |
| instance_out | on success, the instantiated wasmtime_component_instance_t |
NULL is returned, otherwise an error is returned which describes why the build failed. | WASM_API_EXTERN wasmtime_component_linker_t * wasmtime_component_linker_new | ( | const wasm_engine_t * | engine | ) |
Creates a new wasmtime_component_linker_t for the specified engine.
| engine | the compilation environment and configuration |
| WASM_API_EXTERN wasmtime_component_linker_instance_t * wasmtime_component_linker_root | ( | wasmtime_component_linker_t * | linker | ) |
Returns the "root instance" of this linker, used to define names into the root namespace.
linker. The linker MUST not be accessed by anything until the returned wasmtime_component_linker_instance_t in linker_instance_out is destroyed by wasmtime_component_linker_instance_delete.