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

Method alias

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

Aliases one item's name as another. This method will alias an item with the specified `module` and `name` under a new name of `as_module` and `as_name`. # Errors Returns an error if any shadowing violations happen while defining new items, or if the original item wasn't defined. This function will return an [`OutOfMemory`][crate::OutOfMemory] error when memory allocation fails. See the `OutOfM

(
        &mut self,
        module: &str,
        name: &str,
        as_module: &str,
        as_name: &str,
    )

Source from the content-addressed store, hash-verified

995 /// memory allocation fails. See the `OutOfMemory` type's documentation for
996 /// details on Wasmtime's out-of-memory handling.
997 pub fn alias(
998 &mut self,
999 module: &str,
1000 name: &str,
1001 as_module: &str,
1002 as_name: &str,
1003 ) -> Result<&mut Self> {
1004 let src = self.import_key(module, Some(name))?;
1005 let dst = self.import_key(as_module, Some(as_name))?;
1006 match self.map.get(&src).cloned() {
1007 Some(item) => self.insert(dst, item)?,
1008 None => bail!("no item named `{module}::{name}` defined"),
1009 }
1010 Ok(self)
1011 }
1012
1013 /// Aliases one module's name as another.
1014 ///

Callers 3

linker_aliasFunction · 0.80
lift_accessorMethod · 0.80

Calls 4

OkFunction · 0.85
import_keyMethod · 0.80
getMethod · 0.45
insertMethod · 0.45

Tested by 1

linker_aliasFunction · 0.64