MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime-go / DefineModule

Method DefineModule

linker.go:181–198  ·  view source on GitHub ↗

DefineModule defines automatic instantiations of the module in this linker. The `name` of the module is the name within the linker, and the `module` is the one that's being instantiated. This function automatically handles WASI Commands and Reactors for instantiation and initialization. For more in

(store Storelike, name string, module *Module)

Source from the content-addressed store, hash-verified

179// information see the Rust documentation --
180// https://docs.wasmtime.dev/api/wasmtime/struct.Linker.html#method.module.
181func (l *Linker) DefineModule(store Storelike, name string, module *Module) error {
182 err := C.wasmtime_linker_module(
183 l.ptr(),
184 store.Context(),
185 C._GoStringPtr(name),
186 C._GoStringLen(name),
187 module.ptr(),
188 )
189 runtime.KeepAlive(l)
190 runtime.KeepAlive(name)
191 runtime.KeepAlive(module)
192 runtime.KeepAlive(store)
193 if err == nil {
194 return nil
195 }
196
197 return mkError(err)
198}
199
200// DefineUnknownImportsAsTraps defines all otherwise-missing imports of the
201// module as functions that immediately trap.

Callers 1

TestLinkerModuleFunction · 0.95

Calls 3

ptrMethod · 0.95
mkErrorFunction · 0.85
ContextMethod · 0.65

Tested by 1

TestLinkerModuleFunction · 0.76