()
| 36 | } |
| 37 | |
| 38 | fn main() -> Result<()> { |
| 39 | // Create an engine with the component model enabled (disabled by default). |
| 40 | let engine = Engine::new(Config::new().wasm_component_model(true))?; |
| 41 | |
| 42 | // NOTE: The wasm32-unknown-unknown target is used here for simplicity, real world use cases |
| 43 | // should probably use the wasm32-wasip1 target, and enable wasi preview2 within the component |
| 44 | // model. |
| 45 | let component = convert_to_component("target/wasm32-unknown-unknown/debug/guest.wasm")?; |
| 46 | |
| 47 | // Create our component and call our generated host function. |
| 48 | let component = Component::from_binary(&engine, &component)?; |
| 49 | let mut store = Store::new(&engine, MyState {}); |
| 50 | let mut linker = Linker::new(&engine); |
| 51 | host::add_to_linker::<_, HasSelf<_>>(&mut linker, |state| state)?; |
| 52 | let convert = Convert::instantiate(&mut store, &component, &linker)?; |
| 53 | let result = convert.call_convert_celsius_to_fahrenheit(&mut store, 23.4)?; |
| 54 | println!("Converted to: {result:?}"); |
| 55 | Ok(()) |
| 56 | } |
nothing calls this directly
no test coverage detected