Lines Matching refs:plugin
35 Each plugin is a component that supports two operations:
37 that this plugin implements.
41 Two example plugins are included: an `add` plugin implemented in C,
42 and a `subtract` plugin implemented in JavaScript.
44 `c-plugin/add.wasm` and `js-plugin/subtract.wasm`.
49 > (for building the C plugin) and `jco` (for building the JavaScript
50 > plugin). For instructions, see [the C/C++ section](https://component-model.bytecodealliance.org/l…
66 world plugin {
69 export get-plugin-name: func() -> string;
74 The WIT file defines a world that the plugin must implement,
77 there is no functionality in the host that a plugin can call.
79 The world has two exports, indicating that the plugin must implement
80 two functions: a `get-plugin-name` function that returns the name
81 of the operation that this plugin implements, and an `evaluate` function
82 that does computation specific to this plugin.
87 bindgen!("plugin");
98 to execute a plugin given arguments.
120 In this application, we don't need per-plugin state
151 Next let's look at the `load_plugin()` function, which loads a single plugin.
168 let (plugin_name, plugin, store) = {
170 let plugin = Plugin::instantiate(&mut store, &component, linker)?;
171 (plugin.call_get_plugin_name(&mut store)?, plugin, store)
185 automatically by the `bindgen!("plugin")` macro.
187 the `Component` that represents the code for the plugin,
190 The `Plugin` type corresponds to the `plugin` world from our `.wit` file,
193 Now that we have a fully instantiated plugin, we can call its
194 `get-plugin-name` function. The `call_get_plugin_name` method was
196 `call_get_plugin_name` is the same as `get-plugin-name` from the `.wit` file,
199 by the implementation of the method in the plugin, though not in this case
202 Finally, we update the calculator's state by associating the plugin name
203 with a structure containing the plugin and store:
208 .insert(plugin_name, PluginDesc { plugin, store });
225 let result = desc.plugin.call_evaluate(&mut desc.store, self.x, self.y)?;
238 pub plugin: Plugin,
243 Remember, the type `Plugin` corresponds to the `plugin` world and was
249 let result = desc.plugin.call_evaluate(&mut desc.store, self.x, self.y)?;
252 is the one that actually calls into the plugin to do the computation.
272 one in `c-plugin/` (implementing the `add` operation), and one in `js-plugin/`