Wasmtime
component/linker.h
Go to the documentation of this file.
1
2
3#ifndef WASMTIME_COMPONENT_LINKER_H
4#define WASMTIME_COMPONENT_LINKER_H
5
6#include <wasm.h>
7#include <wasmtime/async.h>
11#include <wasmtime/conf.h>
12#include <wasmtime/error.h>
13#include <wasmtime/module.h>
14#include <wasmtime/store.h>
15
16#ifdef WASMTIME_FEATURE_COMPONENT_MODEL
17
18#ifdef __cplusplus
19extern "C" {
20#endif
21
24
28
36WASM_API_EXTERN wasmtime_component_linker_t *
38
45WASM_API_EXTERN void
47 bool allow);
48
60
76 const wasmtime_component_linker_t *linker, wasmtime_context_t *context,
77 const wasmtime_component_t *component,
78 wasmtime_component_instance_t *instance_out);
79
83WASM_API_EXTERN wasmtime_error_t *
85 wasmtime_component_linker_t *linker, const wasmtime_component_t *component);
86
94WASM_API_EXTERN wasmtime_error_t *
97 const wasmtime_component_t *component);
98
105WASM_API_EXTERN void
107
126WASM_API_EXTERN wasmtime_error_t *
128 wasmtime_component_linker_instance_t *linker_instance, const char *name,
129 size_t name_len,
130 wasmtime_component_linker_instance_t **linker_instance_out);
131
146 wasmtime_component_linker_instance_t *linker_instance, const char *name,
147 size_t name_len, const wasmtime_module_t *module);
148
150typedef wasmtime_error_t *(*wasmtime_component_func_callback_t)(
153
167 wasmtime_component_linker_instance_t *linker_instance, const char *name,
168 size_t name_len, wasmtime_component_func_callback_t callback, void *data,
169 void (*finalizer)(void *));
170
171#ifdef WASMTIME_FEATURE_WASI
172
176WASM_API_EXTERN wasmtime_error_t *
178
179#endif // WASMTIME_FEATURE_WASI
180
181#ifdef WASMTIME_FEATURE_WASI_HTTP
182
189WASM_API_EXTERN wasmtime_error_t *
191
192#endif // WASMTIME_FEATURE_WASI_HTTP
193
196typedef wasmtime_error_t *(*wasmtime_component_resource_destructor_t)(
197 void *, wasmtime_context_t *, uint32_t);
198
210WASM_API_EXTERN wasmtime_error_t *
212 wasmtime_component_linker_instance_t *linker_instance, const char *name,
213 size_t name_len, const wasmtime_component_resource_type_t *resource,
214 wasmtime_component_resource_destructor_t destructor, void *data,
215 void (*finalizer)(void *));
216
223 wasmtime_component_linker_instance_t *linker_instance);
224
225#ifdef WASMTIME_FEATURE_COMPONENT_MODEL_ASYNC
226
246WASM_API_EXTERN wasmtime_call_future_t *
248 const wasmtime_component_linker_t *linker, wasmtime_context_t *context,
249 const wasmtime_component_t *component,
250 wasmtime_component_instance_t *instance_out, wasmtime_error_t **error_ret);
251
255 void *env, wasmtime_context_t *context,
257 size_t nargs, wasmtime_component_val_t *results, size_t nresults,
258 wasmtime_error_t **error_ret,
259 wasmtime_async_continuation_t *continuation_ret);
260
276WASM_API_EXTERN wasmtime_error_t *
278 wasmtime_component_linker_instance_t *linker_instance, const char *name,
279 size_t name_len, wasmtime_component_func_async_callback_t callback,
280 void *data, void (*finalizer)(void *));
281
282#ifdef WASMTIME_FEATURE_WASI
283
288WASM_API_EXTERN wasmtime_error_t *
290
291#endif // WASMTIME_FEATURE_WASI
292
293#ifdef WASMTIME_FEATURE_WASI_HTTP
294
301
302#endif // WASMTIME_FEATURE_WASI_HTTP
303
304#endif // WASMTIME_FEATURE_COMPONENT_MODEL_ASYNC
305
306#ifdef __cplusplus
307} // extern "C"
308#endif
309
310#endif // WASMTIME_FEATURE_COMPONENT_MODEL
311
312#endif // WASMTIME_COMPONENT_LINKER_H
Wasmtime async functionality.
struct wasmtime_call_future wasmtime_call_future_t
The structure representing a asynchronously running function.
Definition: async.h:164
struct wasmtime_component_t wasmtime_component_t
Representation of a component in the component model.
Definition: component/component.h:18
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.
struct wasmtime_component_linker_instance_t wasmtime_component_linker_instance_t
Structure representing an "instance" being defined within a linker.
Definition: component/linker.h:26
void(* wasmtime_component_func_async_callback_t)(void *env, wasmtime_context_t *context, const wasmtime_component_func_type_t *ty, wasmtime_component_val_t *args, size_t nargs, wasmtime_component_val_t *results, size_t nresults, wasmtime_error_t **error_ret, wasmtime_async_continuation_t *continuation_ret)
Definition: component/linker.h:254
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.
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.
Definition: component/linker.h:150
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.
wasmtime_error_t *(* wasmtime_component_resource_destructor_t)(void *, wasmtime_context_t *, uint32_t)
Definition: component/linker.h:196
WASM_API_EXTERN wasmtime_error_t * wasmtime_component_linker_add_wasip2_async(wasmtime_component_linker_t *linker)
Add all WASI interfaces into the linker provided using async bindings.
WASM_API_EXTERN wasmtime_error_t * wasmtime_component_linker_add_wasi_http_async(wasmtime_component_linker_t *linker)
Add WASI HTTP interfaces into the linker provided using async bindings.
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.
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.
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.
struct wasmtime_component_linker_t wasmtime_component_linker_t
A type used to instantiate a wasmtime_component_t.
Definition: component/linker.h:23
WASM_API_EXTERN wasmtime_error_t * wasmtime_component_linker_add_wasi_http(wasmtime_component_linker_t *linker)
Add WASI HTTP interfaces into the linker provided.
WASM_API_EXTERN wasmtime_error_t * wasmtime_component_linker_define_unknown_imports_as_default_values(wasmtime_component_linker_t *linker, wasmtime_context_t *store, const wasmtime_component_t *component)
Defines all unknown imports of component as functions which return default values.
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.
WASM_API_EXTERN void wasmtime_component_linker_instance_delete(wasmtime_component_linker_instance_t *linker_instance)
Deletes a wasmtime_component_linker_instance_t.
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.
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.
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 wasmtime_error_t * wasmtime_component_linker_instance_add_func_async(wasmtime_component_linker_instance_t *linker_instance, const char *name, size_t name_len, wasmtime_component_func_async_callback_t callback, void *data, void(*finalizer)(void *))
Define an async function within this instance.
WASM_API_EXTERN wasmtime_call_future_t * wasmtime_component_linker_instantiate_async(const wasmtime_component_linker_t *linker, wasmtime_context_t *context, const wasmtime_component_t *component, wasmtime_component_instance_t *instance_out, wasmtime_error_t **error_ret)
Instantiate a component in linker asynchronously.
struct wasmtime_component_func_type_t wasmtime_component_func_type_t
Opaque type representing a component function type.
Definition: component/types/func.h:18
Build-time defines for how the C API was built.
Definition and accessors of wasmtime_error_t.
struct wasmtime_component_resource_type wasmtime_component_resource_type_t
Represents the type of a component resource.
Definition: resource.h:21
Compilation environment and configuration.
Definition: async.h:115
Representation of a instance in Wasmtime.
Definition: component/instance.h:24
Represents possible runtime values which a component function can either consume or produce.
Definition: component/val.h:383
An interior pointer into a wasmtime_store_t which is used as "context" for many functions.
Errors generated by Wasmtime.
A compiled Wasmtime module.