1use crate::config::{AlefConfig, Language};
2use crate::ir::ApiSurface;
3use std::path::PathBuf;
4
5#[derive(Debug, Clone)]
7pub struct BuildConfig {
8 pub tool: &'static str,
10 pub crate_suffix: &'static str,
12 pub depends_on_ffi: bool,
14 pub post_build: Vec<PostBuildStep>,
16}
17
18#[derive(Debug, Clone)]
20pub enum PostBuildStep {
21 PatchFile {
23 path: &'static str,
25 find: &'static str,
27 replace: &'static str,
29 },
30}
31
32#[derive(Debug, Clone)]
34pub struct GeneratedFile {
35 pub path: PathBuf,
37 pub content: String,
39 pub generated_header: bool,
41}
42
43#[derive(Debug, Clone, Default)]
45pub struct Capabilities {
46 pub supports_async: bool,
47 pub supports_classes: bool,
48 pub supports_enums: bool,
49 pub supports_option: bool,
50 pub supports_result: bool,
51 pub supports_callbacks: bool,
52 pub supports_streaming: bool,
53}
54
55pub trait Backend: Send + Sync {
57 fn name(&self) -> &str;
59
60 fn language(&self) -> Language;
62
63 fn capabilities(&self) -> Capabilities;
65
66 fn generate_bindings(&self, api: &ApiSurface, config: &AlefConfig) -> anyhow::Result<Vec<GeneratedFile>>;
68
69 fn generate_type_stubs(&self, _api: &ApiSurface, _config: &AlefConfig) -> anyhow::Result<Vec<GeneratedFile>> {
71 Ok(vec![])
72 }
73
74 fn generate_scaffold(&self, _api: &ApiSurface, _config: &AlefConfig) -> anyhow::Result<Vec<GeneratedFile>> {
76 Ok(vec![])
77 }
78
79 fn generate_public_api(&self, _api: &ApiSurface, _config: &AlefConfig) -> anyhow::Result<Vec<GeneratedFile>> {
81 Ok(vec![])
82 }
83
84 fn build_config(&self) -> Option<BuildConfig> {
86 None
87 }
88}