Skip to main content

Crate connectrpc_build

Crate connectrpc_build 

Source
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§

CodeGenConfig
Configuration for code generation.
Config
Builder for configuring and running connectrpc code generation.

Enums§

EncodableImpls
Which messages get generated ::connectrpc::Encodable view impl pairs. See Options::encodable_impls.