pub trait CodegenBackend {
// Required methods
fn lang(&self) -> &str;
fn validate_lang_options(&self, options: &Value) -> Result<(), Vec<String>>;
fn generate(
&self,
ir: &ValidatedDef,
config: &GenTarget,
) -> Result<String, CodegenError>;
fn formatter_command(&self) -> Option<&[&str]>;
}Expand description
Trait for language-specific code generation backends.
Required Methods§
Sourcefn validate_lang_options(&self, options: &Value) -> Result<(), Vec<String>>
fn validate_lang_options(&self, options: &Value) -> Result<(), Vec<String>>
Validate language-specific options from the lang_options config field.
Returns errors for unknown or invalid keys.
Sourcefn generate(
&self,
ir: &ValidatedDef,
config: &GenTarget,
) -> Result<String, CodegenError>
fn generate( &self, ir: &ValidatedDef, config: &GenTarget, ) -> Result<String, CodegenError>
Generate source code from the decoder IR and configuration.
Sourcefn formatter_command(&self) -> Option<&[&str]>
fn formatter_command(&self) -> Option<&[&str]>
Optional: command to format the generated source.