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:
- Analysis: Process collected metadata to understand service structure
- Planning: Determine what code needs to be generated
- Generation: Create Rust code using templates and metadata
- 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§
- Bindings
Config - Configuration for language-binding code generation (Python / Node.js).
- Code
GenConfig - Configuration for code generation, including import paths and output directories.
- Code
GenOutput - Output directory configuration for code generation.
- Generated
Code - Generated code ready for output
- Models
Path - Validated model import path derived from a
{service}template string.
Functions§
- generate_
code - Generate all code described by
configfrommetadata. - generate_
models_ mod - Generate the
mod.rsforcrates/common/src/models/. - main_
module