1pub mod config;
2pub mod error;
3pub mod ir;
4pub mod parse;
5pub mod transform;
6
7use thiserror::Error;
8
9#[derive(Debug, Clone)]
11pub struct GeneratedFile {
12 pub path: String,
13 pub content: String,
14}
15
16#[derive(Debug, Error)]
18pub enum GeneratorError {
19 #[error("template render failed: {0}")]
20 Render(String),
21
22 #[error("generation failed: {0}")]
23 Other(String),
24}
25
26pub trait CodeGenerator {
28 fn id(&self) -> config::GeneratorId;
29 fn generate(
30 &self,
31 ir: &ir::IrSpec,
32 config: &config::GeneratorConfig,
33 ) -> Result<Vec<GeneratedFile>, GeneratorError>;
34}