1use anyhow::Result;
2use camino::Utf8Path;
3use weaveffi_ir::ir::Api;
4
5pub trait Generator {
6 fn name(&self) -> &'static str;
7 fn generate(&self, api: &Api, out_dir: &Utf8Path) -> Result<()>;
8}
9
10#[derive(Default)]
11pub struct Orchestrator<'a> {
12 generators: Vec<&'a dyn Generator>,
13}
14
15impl<'a> Orchestrator<'a> {
16 pub fn new() -> Self {
17 Self::default()
18 }
19
20 pub fn with_generator(mut self, gen: &'a dyn Generator) -> Self {
21 self.generators.push(gen);
22 self
23 }
24
25 pub fn run(&self, api: &Api, out_dir: &Utf8Path) -> Result<()> {
26 for g in &self.generators {
27 g.generate(api, out_dir)?;
28 }
29 Ok(())
30 }
31}