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