Wasmtime
wasmtime::component::LinkerInstance Class Reference

Helper class for linking modules together with name-based resolution. More...

#include <linker.hh>

Public Member Functions

 LinkerInstance (wasmtime_component_linker_instance_t *ptr)
 Creates a new linker instance from the given C API pointer.
 
const wasmtime_component_linker_instance_tcapi () const
 Returns the underlying C API pointer.
 
wasmtime_component_linker_instance_tcapi ()
 Returns the underlying C API pointer.
 
Result< std::monostate > add_module (std::string_view name, Module &module)
 Adds a module to this linker instance under the specified name.
 
Result< LinkerInstanceadd_instance (std::string_view name)
 Adds an new instance to this linker instance under the specified name. More...
 
template<typename F , std::enable_if_t< std::is_invocable_r_v< Result< std::monostate >, F, Store::Context, Span< const Val >, Span< Val > >, bool > = true>
Result< std::monostate > add_func (std::string_view name, F &&f)
 Defines a function within this linker instance.
 
template<typename F , std::enable_if_t< std::is_invocable_r_v< Result< std::monostate >, F, Store::Context, uint32_t >, bool > = true>
Result< std::monostate > add_resource (std::string_view name, const ResourceType &ty, F &&f)
 Defines a new resource in this linker with the provided destructor.
 

Detailed Description

Helper class for linking modules together with name-based resolution.

This class is used for easily instantiating Modules by defining names into the linker and performing name-based resolution during instantiation. A Linker can also be used to link in WASI functions to instantiate a module.

Member Function Documentation

◆ add_instance()

Result< LinkerInstance > wasmtime::component::LinkerInstance::add_instance ( std::string_view  name)
inline

Adds an new instance to this linker instance under the specified name.

Note that this LinkerInstance can no longer be used until the returned LinkerInstance is dropped.


The documentation for this class was generated from the following file: