specfold_core/plugins/
registry.rs1use super::process;
4use super::protocol::{Description, PROTOCOL};
5use crate::config::{Config, PluginDef};
6use anyhow::{Result, bail};
7
8pub struct Loaded {
9 pub def: PluginDef,
10 pub description: Result<Description>,
11}
12
13pub fn describe(cfg: &Config, p: &PluginDef) -> Result<Description> {
14 let d: Description = process::call(cfg, p, "describe", serde_json::Value::Null)?;
15 if d.protocol != PROTOCOL {
16 bail!("plugin {} speaks '{}', this specfold speaks {PROTOCOL}", p.name, d.protocol);
17 }
18 Ok(d)
19}
20
21pub fn load(cfg: &Config) -> Vec<Loaded> {
23 cfg.raw.plugins.iter().map(|p| Loaded { def: p.clone(), description: describe(cfg, p) }).collect()
24}