Skip to main content

Crate buffa_codegen

Crate buffa_codegen 

Source
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 .proto files.
  • 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§

CodeGenConfig
Configuration for code generation.
GeneratedFile
One generated output file.

Enums§

CodeGenError
Code generation error.
GeneratedFileKind
Kind of GeneratedFile.
IncludeMode
How generate_module_tree emits include! paths.

Constants§

ALLOW_LINTS
Lints suppressed on generated code at module boundaries.

Functions§

allow_lints_attr
Render ALLOW_LINTS as a #[allow(…)] attribute token stream.
apply_companions
Merge downstream Companion files into the per-package stitcher produced by generate.
generate
Generate Rust source files from a set of file descriptors.
generate_module_tree
Generate a module tree that assembles per-package .mod.rs files into nested pub mod blocks matching the protobuf package hierarchy.
package_to_filename
Convert a proto package name to its file_per_package output filename.
package_to_mod_filename
Convert a proto package name to its .mod.rs stitcher filename.
proto_path_to_stem
Convert a .proto file path to its content-file stem.