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).
- Client
Protocols - Which client protocol layer(s) to emit.
- Code
GenConfig - Configuration for code generation, including import paths and output directories.
- Code
GenOutput - Output directory configuration for code generation.
- Generated
Code - An in-memory bundle of generated source files awaiting output.
- Models
Path - Validated model import path derived from a
{service}template string.
Enums§
- Client
Protocol - Wire protocol a generated client speaks.
- Python
Api - Which Python client flavors the PyO3 bindings expose.
- Runtime
- Protobuf runtime that the generated code is expected to consume.
Constants§
- DEFAULT_
TRANSPORT_ TYPE_ PATH - Default transport type path: the cloud client used by native (non-WASM) generated code.
Functions§
- generate_
code - Generate all code described by
configfrommetadata. - generate_
models_ mod - Generate the
mod.rsforcrates/common/src/models/. - main_
module