pub trait TranspilerPlugin: Send + Sync {
// Required methods
fn metadata(&self) -> PluginMetadata;
fn transpile(&self, source: &str, language: Language) -> Result<String>;
// Provided methods
fn initialize(&mut self) -> Result<()> { ... }
fn transpile_file(&self, path: &Path, language: Language) -> Result<String> { ... }
fn validate(&self, _original: &str, _transpiled: &str) -> Result<()> { ... }
fn cleanup(&mut self) -> Result<()> { ... }
}Expand description
Core trait for transpiler plugins
Implement this trait to create custom transpilers that integrate with Batuta’s pipeline.
Required Methods§
Sourcefn metadata(&self) -> PluginMetadata
fn metadata(&self) -> PluginMetadata
Get plugin metadata
Provided Methods§
Sourcefn initialize(&mut self) -> Result<()>
fn initialize(&mut self) -> Result<()>
Initialize the plugin
Called once when the plugin is loaded. Use this for setup tasks like:
- Loading configuration
- Initializing caches
- Validating dependencies
Sourcefn transpile_file(&self, path: &Path, language: Language) -> Result<String>
fn transpile_file(&self, path: &Path, language: Language) -> Result<String>
Transpile a file
Default implementation reads the file and calls transpile().
Override for custom file handling (e.g., imports, multi-file projects).