Get a function export by name. ## Example ```rust # fn main() -> tinywasm::Result<()> { # use tinywasm::{ModuleInstance, Store}; # use tinywasm::types::WasmValue; # let wasm = wat::parse_str(r#" # (module # (func (export "add") (param i32 i32) (result i32) # local.get 0 # local.get 1 # i32.add)) # "#).expect("valid wat"); # let module = tinywasm::parse_bytes(&was
(&self, store: &Store, name: &str)
| 414 | /// |
| 415 | /// For typed access, see [`Self::func`]. |
| 416 | pub fn func_untyped(&self, store: &Store, name: &str) -> Result<Function> { |
| 417 | self.validate_store(store)?; |
| 418 | |
| 419 | let func_addr = match self.require_export(name)? { |
| 420 | ExternVal::Func(func_addr) => func_addr, |
| 421 | _ => { |
| 422 | cold_path(); |
| 423 | return Err(Error::Other(format!("Export is not a function: {name}"))); |
| 424 | } |
| 425 | }; |
| 426 | |
| 427 | Ok(Function { |
| 428 | item: crate::StoreItem::new(self.0.store_id, func_addr), |
| 429 | addr: func_addr, |
| 430 | module_addr: self.id(), |
| 431 | ty: store.state.get_func(func_addr).ty().clone(), |
| 432 | }) |
| 433 | } |
| 434 | |
| 435 | /// Get a function by its module-local index. |
| 436 | /// |