Skip to main content

CodegenBackend

Trait CodegenBackend 

Source
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§

Source

fn lang(&self) -> &str

Language identifier (e.g., "rust").

Source

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.

Source

fn generate( &self, ir: &ValidatedDef, config: &GenTarget, ) -> Result<String, CodegenError>

Generate source code from the decoder IR and configuration.

Source

fn formatter_command(&self) -> Option<&[&str]>

Optional: command to format the generated source.

Implementors§