MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / load_plugins

Function load_plugins

examples/wasip2-plugins/src/main.rs:96–111  ·  view source on GitHub ↗
(state: &mut CalculatorState, plugins_dir: &Path)

Source from the content-addressed store, hash-verified

94}
95
96fn load_plugins(state: &mut CalculatorState, plugins_dir: &Path) -> wasmtime::Result<()> {
97 let engine = Engine::default();
98 let linker: Linker<()> = Linker::new(&engine);
99
100 if !plugins_dir.is_dir() {
101 wasmtime::bail!("plugins directory does not exist");
102 }
103
104 for entry in fs::read_dir(plugins_dir)? {
105 let path = entry?.path();
106 if path.is_file() && path.extension().and_then(OsStr::to_str) == Some("wasm") {
107 load_plugin(state, &engine, &linker, path)?;
108 }
109 }
110 Ok(())
111}
112
113#[derive(Parser)]
114#[command(name = "calculator-host", version = env!("CARGO_PKG_VERSION"))]

Callers 1

mainFunction · 0.85

Calls 6

read_dirFunction · 0.85
load_pluginFunction · 0.85
OkFunction · 0.85
is_dirMethod · 0.80
newFunction · 0.50
pathMethod · 0.45

Tested by

no test coverage detected