(
state: &mut CalculatorState,
engine: &Engine,
linker: &Linker<()>,
path: PathBuf,
)
| 66 | } |
| 67 | |
| 68 | fn load_plugin( |
| 69 | state: &mut CalculatorState, |
| 70 | engine: &Engine, |
| 71 | linker: &Linker<()>, |
| 72 | path: PathBuf, |
| 73 | ) -> wasmtime::Result<()> { |
| 74 | println!("Loading plugin from file {:?}", path); |
| 75 | |
| 76 | // Creates a component from a .wasm file |
| 77 | let component = Component::from_file(engine, &path)?; |
| 78 | |
| 79 | let (plugin_name, plugin, store) = { |
| 80 | // Creates a Store for each plugin. |
| 81 | // A Store represents dynamic state, so each plugin |
| 82 | // has its own Store. |
| 83 | let mut store = Store::new(engine, ()); |
| 84 | // Instantiate the plugin to the store we just created. |
| 85 | let plugin = Plugin::instantiate(&mut store, &component, linker)?; |
| 86 | (plugin.call_get_plugin_name(&mut store)?, plugin, store) |
| 87 | }; |
| 88 | |
| 89 | state |
| 90 | .plugin_descs |
| 91 | .insert(plugin_name, PluginDesc { plugin, store }); |
| 92 | |
| 93 | Ok(()) |
| 94 | } |
| 95 | |
| 96 | fn load_plugins(state: &mut CalculatorState, plugins_dir: &Path) -> wasmtime::Result<()> { |
| 97 | let engine = Engine::default(); |
no test coverage detected