Skip to content

Add connectrpc/rust plugin v0.2.0#2334

Draft
iainmcgin wants to merge 1 commit intobufbuild:mainfrom
iainmcgin:add-connectrpc-rust-plugin
Draft

Add connectrpc/rust plugin v0.2.0#2334
iainmcgin wants to merge 1 commit intobufbuild:mainfrom
iainmcgin:add-connectrpc-rust-plugin

Conversation

@iainmcgin
Copy link

Adds the protoc-gen-connect-rust plugin for ConnectRPC Rust service bindings.

About connect-rust

connect-rust is a Tower-based Rust implementation of the ConnectRPC protocol:

  • Three protocols: Connect, gRPC, gRPC-Web - same service impl handles all three
  • Full conformance: 3600 server tests, 2580/1454/2838 client tests across Connect/gRPC/gRPC-Web
  • Zero-copy request handling via buffa view types - request.name is a &str borrow into the decoded buffer
  • Tower integration: composes with axum, hyper, tower middleware

Crates on crates.io: connectrpc, connectrpc-codegen, connectrpc-build.

Plugin layering

The plugin emits service stubs only - server traits, typed clients, monomorphic dispatchers. Message types come from buf.build/community/anthropics-buffa (declared in deps:). Generated stubs reference message types via absolute Rust paths (crate::<buffa_sdk>::pkg::Type).

Dockerfile note: the protoc-gen-connect-rust binary is a [[bin]] target inside the connectrpc-codegen crate, so cargo install connectrpc-codegen is what produces it.

Open question: extern_path injection

The plugin needs to know where the buffa SDK crate lives to emit the right paths. It accepts either extern_path=.=<rust_path> (same format as tonic/prost) or the shorthand buffa_module=<rust_path>.

I left opts: [] with a comment in the yaml because I assume BSR injects extern_path=.=::<buffa_sdk_crate_name> at invocation time based on the deps: config - same as it does for tonic referencing prost types. Would appreciate confirmation of the exact value BSR injects so I can verify the plugin handles it correctly.

Dependencies

Depends on the buffa plugin landing first: #2333

Process note

CONTRIBUTING.md asks for an issue first - happy to open one if you would prefer to discuss before reviewing. Filed as draft.

connect-rust is a Tower-based Rust implementation of the ConnectRPC
protocol. Generates service traits, typed clients, and monomorphic
dispatchers. Compatible with Connect, gRPC, and gRPC-Web; passes the
full ConnectRPC conformance suite (3600 server tests, 6872 client
tests across protocols).

The plugin emits service stubs only. Message types come from the buffa
plugin (declared as a dep here). Generated stubs reference message
types via absolute paths; the plugin accepts `extern_path=.=<path>` to
configure the root. Left `opts: []` with a comment asking how BSR
injects the dep crate path - same mechanism as tonic/prost presumably,
but want to confirm the exact value.

Note: the protoc-gen-connect-rust binary is a [[bin]] target in the
connectrpc-codegen crate, so the Dockerfile installs connectrpc-codegen
by name and copies the binary out.

Depends on buf.build/community/anthropics-buffa:v0.2.0 (separate PR).

Crates: https://crates.io/crates/connectrpc-codegen
Repo: https://github.com/anthropics/connect-rust
@bufdev
Copy link
Member

bufdev commented Mar 19, 2026

#2333 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants