Third-party protos compiled for the buffa Rust protobuf runtime.
buffa-types carries the protobuf well-known types — the ones that ship
with protoc. This carries the other ones a service ends up needing. Today that
is google.rpc.
| Package | Holds |
|---|---|
google.rpc |
Status, the Code enum, and the error_details.proto payloads that go in Status.details — BadRequest, RetryInfo, ErrorInfo, QuotaFailure, PreconditionFailure, ResourceInfo, RequestInfo, Help, LocalizedMessage, DebugInfo |
Vendored from googleapis, generated with the pinned plugin in
buf.gen.yaml, and committed — so a consumer needs neither buf nor
protoc to build.
Because google.rpc.Status is a shared type, and generating it into each
service makes it a different Rust type in each one. A Status built by a
library cannot then be assigned to a Status field on a message generated
somewhere else, and the compiler is right to refuse — they are unrelated types
that happen to share a name.
That is the same reason google.protobuf lives in buffa-types rather than
being emitted into every crate that mentions a Timestamp.
It is also 8,000-odd lines a service does not have to carry or regenerate.
Point the buffa codegen at this crate instead of generating the package again:
- remote: buf.build/anthropics/buffa:v0.9.1
out: src/proto
include_imports: true
opt:
- file_per_package=true
# Do not generate the package...
- exclude_package=.google.rpc
# ...name it here instead.
- extern_path=.google.rpc=::buffa_protos::google::rpcbuffa-protos = { git = "https://github.com/protoc-contrib/buffa-protos", rev = "..." }Pin a rev. This is a git dependency with no published releases, so a branch
would mean the crate can change under a build that did not ask it to.
The module path mirrors the proto package — google.rpc.Status is
buffa_protos::google::rpc::Status — which is what lets the extern_path be a
single package-prefix mapping rather than one entry per type.
- Vendor the
.protounderproto/. - Run
buf generate --clean. - Mount the emitted
<package>.rsinsrc/lib.rs, and add it to theignorelist inrustfmt.toml.
Anything the new package imports from google.protobuf resolves to
buffa-types with no further configuration — that is the extern_path already
in buf.gen.yaml, and it is what stops this crate shipping a second Any.
Anything it imports from a package this crate does not carry has to be vendored
alongside it.
--clean matters: the output is committed, so a package renamed or removed
upstream would otherwise leave a stale file behind that still compiles. CI
regenerates and fails on any diff, which catches both that and a moved pin.
nix develop # cargo, rustc, clippy, rustfmt, buf
cargo test
buf generate --clean && git diff --exit-code -- src/generatedbuf is for regenerating only. The generated code is committed, so building
this crate — or anything depending on it — needs neither buf nor protoc.
The vendored protos are Google's, Apache-2.0. This repository is Apache-2.0; see LICENSE.