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,
)
| 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 | /// |