MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / define

Method define

crates/wasmtime/src/runtime/linker.rs:362–376  ·  view source on GitHub ↗

Defines a new item in this [`Linker`]. This method will add a new definition, by name, to this instance of [`Linker`]. The `module` and `name` provided are what to name the `item`. # Errors Returns an error if the `module` and `name` already identify an item of the same type as the `item` provided and if shadowing is disallowed. For more information see the documentation on [`Linker`]. # Examp

(
        &mut self,
        store: impl AsContext<Data = T>,
        module: &str,
        name: &str,
        item: impl Into<Extern>,
    )

Source from the content-addressed store, hash-verified

360 /// memory allocation fails. See the `OutOfMemory` type's documentation for
361 /// details on Wasmtime's out-of-memory handling.
362 pub fn define(
363 &mut self,
364 store: impl AsContext<Data = T>,
365 module: &str,
366 name: &str,
367 item: impl Into<Extern>,
368 ) -> Result<&mut Self>
369 where
370 T: 'static,
371 {
372 let store = store.as_context();
373 let key = self.import_key(module, Some(name))?;
374 self.insert(key, Definition::new(store.0, item.into()))?;
375 Ok(self)
376 }
377
378 /// Same as [`Linker::define`], except only the name of the import is
379 /// provided, not a module name as well.

Callers 13

link_spectestFunction · 0.45
run_directiveMethod · 0.45
mainFunction · 0.45
build_c_helpersFunction · 0.45
mainFunction · 0.45
add_to_linkerFunction · 0.45
gc_opsFunction · 0.45
exception_opsFunction · 0.45
dummy_linkerFunction · 0.45
linker_defineFunction · 0.45

Calls 5

OkFunction · 0.85
import_keyMethod · 0.80
newFunction · 0.50
as_contextMethod · 0.45
insertMethod · 0.45

Tested by 4

link_spectestFunction · 0.36
linker_defineFunction · 0.36
wizen_and_run_wasmFunction · 0.36