use crate::config::{AlefConfig, Language};
use crate::ir::ApiSurface;
use std::path::PathBuf;
#[derive(Debug, Clone)]
pub struct BuildConfig {
pub tool: &'static str,
pub crate_suffix: &'static str,
pub depends_on_ffi: bool,
pub post_build: Vec<PostBuildStep>,
}
#[derive(Debug, Clone)]
pub enum PostBuildStep {
PatchFile {
path: &'static str,
find: &'static str,
replace: &'static str,
},
}
#[derive(Debug, Clone)]
pub struct GeneratedFile {
pub path: PathBuf,
pub content: String,
pub generated_header: bool,
}
#[derive(Debug, Clone, Default)]
pub struct Capabilities {
pub supports_async: bool,
pub supports_classes: bool,
pub supports_enums: bool,
pub supports_option: bool,
pub supports_result: bool,
pub supports_callbacks: bool,
pub supports_streaming: bool,
}
pub trait Backend: Send + Sync {
fn name(&self) -> &str;
fn language(&self) -> Language;
fn capabilities(&self) -> Capabilities;
fn generate_bindings(&self, api: &ApiSurface, config: &AlefConfig) -> anyhow::Result<Vec<GeneratedFile>>;
fn generate_type_stubs(&self, _api: &ApiSurface, _config: &AlefConfig) -> anyhow::Result<Vec<GeneratedFile>> {
Ok(vec![])
}
fn generate_scaffold(&self, _api: &ApiSurface, _config: &AlefConfig) -> anyhow::Result<Vec<GeneratedFile>> {
Ok(vec![])
}
fn generate_public_api(&self, _api: &ApiSurface, _config: &AlefConfig) -> anyhow::Result<Vec<GeneratedFile>> {
Ok(vec![])
}
fn build_config(&self) -> Option<BuildConfig> {
None
}
}