Skip to main content

generate_files

Function generate_files 

Source
pub fn generate_files(
    proto_file: &[FileDescriptorProto],
    file_to_generate: &[String],
    options: &Options,
) -> Result<Vec<GeneratedFile>>
Expand description

Generate ConnectRPC service bindings + buffa message types from proto descriptors.

Returns buffa’s per-proto GeneratedFiles (Owned, View, Oneof, ViewOneof, Ext, plus one PackageMod stitcher per package), with one GeneratedFileKind::Companion file per service-declaring proto (<stem>.__connect.rs) wired into the matching package stitcher via buffa_codegen::apply_companions. Callers write every file to disk and wire only the GeneratedFileKind::PackageMod entries into their module tree (the stitchers include! the rest).

Under CodeGenConfig::file_per_package no Companion files are emitted: the service stubs are inlined directly into buffa’s single <dotted.pkg>.rs PackageMod per package, mirroring how buffa inlines its own ancillary content under that mode.

This is the unified path: service stubs reference message types via super::-relative paths, so both must live in the same module tree. CodeGenConfig::extern_paths is ignored.

§Errors

Returns an error if buffa-codegen fails (e.g. unsupported proto feature) or if the generated service binding Rust does not parse under syn (indicates a bug in this crate).