Skip to main content

generate_code

Function generate_code 

Source
pub fn generate_code(
    metadata: &CodeGenMetadata,
    config: &CodeGenConfig,
) -> Result<()>
Expand description

Generate all code described by config from metadata.

Writes the following outputs, depending on which CodeGenOutput fields are Some:

FieldContents
output.commonAxum extractor code, per-service mod.rs (always written)
output.models_genlabels.rs resource-enum file (falls back to common if None)
output.serverHandler trait + Axum route wiring per service
output.clientHTTP client structs and request builders per service
output.pythonPyO3 binding wrappers + .pyi typings stub
output.nodeNAPI binding wrappers
output.node_tsTypeScript client (client.ts)

§Required fields

  • output.common is always required.
  • bindings must be Some when any of output.python, output.node, or output.node_ts is Some; otherwise returns Error::MissingBindingsConfig.
  • models_path_template and models_path_crate_template must be valid Rust path templates (containing {service}); invalid templates return Error::InvalidModelsPathTemplate.

§Optional fields

Setting generate_resource_enum to false skips labels.rs generation. Setting bindings to None skips all language-binding output.

Call CodeGenConfig::validate before this function to surface config errors at construction time rather than mid-generation.