Expand description
Shared code generation logic for buffa.
This crate takes protobuf descriptors (google.protobuf.FileDescriptorProto,
decoded from binary FileDescriptorSet data) and emits Rust source code
that uses the buffa runtime.
It is used by:
protoc-gen-buffa(protoc plugin)buffa-build(build.rs integration)
§Architecture
The code generator is intentionally decoupled from how descriptors are
obtained. It receives fully-resolved FileDescriptorProtos and produces
Rust source strings. This means:
- It doesn’t parse
.protofiles. - It doesn’t invoke
protoc. - It doesn’t do import resolution or name linking.
All of that is handled upstream (by protoc, buf, or a future parser).
Modules§
- context
- Code generation context and descriptor-to-Rust mapping state.
- idents
- Rust identifier and path construction helpers.
Structs§
- Alias
Conflict - One CamelCase collision: a target identifier and the proto value names that would all convert onto it.
- Code
GenConfig - Configuration for code generation.
- Generated
File - One generated output file.
Enums§
- Code
GenError - Code generation error.
- Code
GenWarning - A non-fatal diagnostic produced during code generation.
- Generated
File Kind - Kind of
GeneratedFile. - Include
Mode - How
generate_module_treeemitsinclude!paths. - Reflect
Mode - How much reflection support generated types get.
- String
Repr - The Rust type a proto
stringfield maps to in generated owned structs.
Constants§
- ALLOW_
LINTS - Lints suppressed on generated code at module boundaries.
Functions§
- allow_
lints_ attr - Render
ALLOW_LINTSas a#[allow(…)]attribute token stream. - apply_
companions - Merge downstream
Companionfiles into the per-package stitcher produced bygenerate. - generate
- Generate Rust source files from a set of file descriptors.
- generate_
module_ tree - Generate a module tree that assembles per-package
.mod.rsfiles into nestedpub modblocks matching the protobuf package hierarchy. - generate_
with_ diagnostics - Like
generate, but also returns the non-fatalCodeGenWarnings collected during generation (e.g. enums whose idiomatic CamelCase aliases were suppressed by a naming conflict). - package_
to_ filename - Convert a proto package name to its
file_per_packageoutput filename. - package_
to_ mod_ filename - Convert a proto package name to its
.mod.rsstitcher filename. - proto_
path_ to_ stem - Convert a
.protofile path to its content-file stem.