Skip to main content

Module codegen

Module codegen 

Source
Expand description

Code generation module for REST API handlers and language bindings.

This module provides the core functionality for generating Rust code from protobuf metadata extracted from service definitions.

§Architecture

The code generation process follows these phases:

  1. Analysis: Process collected metadata to understand service structure
  2. Planning: Determine what code needs to be generated
  3. Generation: Create Rust code using templates and metadata
  4. Output: Write generated code to appropriate files

§Generated Code Types

  • Handler Traits: Async trait definitions for service operations
  • Request Extractors: Axum FromRequest/FromRequestParts implementations
  • Route Handlers: Axum handler functions that delegate to traits
  • Client Code: HTTP client implementations for services
  • Type Mappings: Conversions between protobuf and Rust types

Structs§

BindingsConfig
Configuration for language-binding code generation (Python / Node.js).
CodeGenConfig
Configuration for code generation, including import paths and output directories.
CodeGenOutput
Output directory configuration for code generation.
GeneratedCode
Generated code ready for output
ModelsPath
Validated model import path derived from a {service} template string.

Functions§

generate_code
Generate all code described by config from metadata.
generate_models_mod
Generate the mod.rs for crates/common/src/models/.
main_module