Wasmtime
component/func.h File Reference
#include <wasmtime/component/val.h>
#include <wasmtime/conf.h>
#include <wasmtime/error.h>
#include <wasmtime/store.h>

Go to the source code of this file.

Data Structures

struct  wasmtime_component_func
 Representation of a function in Wasmtime. More...
 

Typedefs

typedef struct wasmtime_component_func wasmtime_component_func_t
 Representation of a function in Wasmtime. More...
 

Functions

wasmtime_error_twasmtime_component_func_call (const wasmtime_component_func_t *func, wasmtime_context_t *context, const wasmtime_component_val_t *args, size_t args_size, wasmtime_component_val_t *results, size_t results_size)
 Invokes func with the args given and returns the result. More...
 
wasmtime_error_twasmtime_component_func_post_return (const wasmtime_component_func_t *func, wasmtime_context_t *context)
 Invokes the post-return canonical ABI option, if specified, after a wasmtime_component_func_call has finished. More...
 

Typedef Documentation

◆ wasmtime_component_func_t

Representation of a function in Wasmtime.

Functions in Wasmtime are represented as an index into a store and don't have any data or destructor associated with the value. Functions cannot interoperate between wasmtime_store_t instances and if the wrong function is passed to the wrong store then it may trigger an assertion to abort the process.

Function Documentation

◆ wasmtime_component_func_call()

wasmtime_error_t * wasmtime_component_func_call ( const wasmtime_component_func_t func,
wasmtime_context_t context,
const wasmtime_component_val_t args,
size_t  args_size,
wasmtime_component_val_t results,
size_t  results_size 
)

Invokes func with the args given and returns the result.

The args provided must match the parameters that this function takes in terms of their types and the number of parameters. Results will be written to the results provided if the call completes successfully. The initial types of the values in results are ignored and values are overwritten to write the result. It's required that the results_size exactly matches the number of results that this function produces.

◆ wasmtime_component_func_post_return()

wasmtime_error_t * wasmtime_component_func_post_return ( const wasmtime_component_func_t func,
wasmtime_context_t context 
)

Invokes the post-return canonical ABI option, if specified, after a wasmtime_component_func_call has finished.

This function is a required method call after a wasmtime_component_func_call completes successfully. After the embedder has finished processing the return value then this function must be invoked.