use anyhow::{Context, Result};
use camino::Utf8PathBuf;
use extism::{Manifest, Plugin, Wasm};
use odk_schema::CompiledSchema;
pub fn load_schema_from_plugin(plugin_path: &Utf8PathBuf) -> Result<CompiledSchema> {
let wasm = Wasm::file(plugin_path.as_std_path());
let manifest = Manifest::new([wasm]);
let mut plugin = Plugin::new(&manifest, [], true)
.with_context(|| format!("Failed to load WASM plugin from {}", plugin_path))?;
let result = plugin
.call::<_, &str>("get_schema", "")
.with_context(|| "Failed to call get_schema function in plugin")?;
let schema = CompiledSchema::from_json(result)
.with_context(|| "Failed to parse schema JSON from plugin")?;
Ok(schema)
}
#[cfg(test)]
mod tests {
}