pub fn generate_services(
proto_file: &[FileDescriptorProto],
file_to_generate: &[String],
options: &Options,
) -> Result<Vec<GeneratedFile>>Expand description
Generate only ConnectRPC service bindings from proto descriptors.
Returns one <stem>.__connect.rs GeneratedFile per proto file in
file_to_generate that declares at least one service, plus one
<pkg>.mod.rs stitcher per package. No message types.
Service files carry GeneratedFileKind::Companion for symmetry with
generate_files, even though this path never calls
apply_companions: the split-path stitcher emitted here include!s
them directly. Build integrations filtering on kind should treat
Companion as “connect-rust service stub” in both modes.
Under CodeGenConfig::file_per_package the per-proto split is
collapsed: the output is exactly one <dotted.pkg>.rs (kind
GeneratedFileKind::PackageMod) per package with all service stubs
inlined, and no <pkg>.mod.rs stitcher. This matches the file layout
protoc-gen-buffa produces under the same option and the convention
that BSR cargo SDK generation and tonic-style build integrations
expect (one <dotted.package>.rs per package, module tree synthesised
from filenames). Route this output to its own directory — it shares
protoc-gen-buffa’s filename per package and would silently overwrite
in a shared one.
This is the split path: service stubs reference message types via
absolute Rust paths derived from CodeGenConfig::extern_paths. Callers must
set at least a . catch-all entry (e.g. (".", "crate::proto")) so
every type resolves; the auto-injected WKT mapping still takes priority
via longest-prefix-match. The generated code compiles standalone as long
as the extern paths point at a buffa-generated module tree.
§Errors
Errors if any method input/output type is not covered by an extern_path
mapping, or is absent from proto_file (missing import).