Expand description
Build-time integration for connectrpc.
Use this crate in build.rs to compile .proto files into Rust code at
build time. It shells out to protoc (or buf, or reads a precompiled
FileDescriptorSet) to obtain descriptors, then runs
connectrpc_codegen to emit buffa message types plus ConnectRPC
service traits and clients into $OUT_DIR.
§Example
ⓘ
// build.rs
fn main() {
connectrpc_build::Config::new()
.files(&["proto/my_service.proto"])
.includes(&["proto/"])
.include_file("_connectrpc.rs")
.compile()
.unwrap();
}ⓘ
// lib.rs
connectrpc::include_generated!();§Requirements
Requires protoc on PATH (or set via PROTOC). To use buf instead,
call Config::use_buf. To avoid both, precompile a FileDescriptorSet
once and ship it alongside your source via Config::descriptor_set.
To embed the compiled FileDescriptorSet in your binary — for example
to back gRPC server reflection — see Config::emit_descriptor_set.
Structs§
- Code
GenConfig - Configuration for code generation.
- Config
- Builder for configuring and running connectrpc code generation.
Enums§
- Encodable
Impls - Which messages get generated
::connectrpc::Encodableview impl pairs. SeeOptions::encodable_impls.