From 61b03f32aead1e7a1070f69a63e7013c7fe0a534 Mon Sep 17 00:00:00 2001 From: Iain McGinniss <309153+iainmcgin@users.noreply.github.com> Date: Tue, 17 Mar 2026 01:59:52 +0000 Subject: [PATCH] Add connectrpc/rust plugin v0.2.0 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=.=` 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 --- plugins/connectrpc/rust/source.yaml | 4 ++ plugins/connectrpc/rust/v0.2.0/.dockerignore | 2 + plugins/connectrpc/rust/v0.2.0/Dockerfile | 17 ++++++++ .../connectrpc/rust/v0.2.0/buf.plugin.yaml | 40 +++++++++++++++++++ 4 files changed, 63 insertions(+) create mode 100644 plugins/connectrpc/rust/source.yaml create mode 100644 plugins/connectrpc/rust/v0.2.0/.dockerignore create mode 100644 plugins/connectrpc/rust/v0.2.0/Dockerfile create mode 100644 plugins/connectrpc/rust/v0.2.0/buf.plugin.yaml diff --git a/plugins/connectrpc/rust/source.yaml b/plugins/connectrpc/rust/source.yaml new file mode 100644 index 000000000..1c02a0aa6 --- /dev/null +++ b/plugins/connectrpc/rust/source.yaml @@ -0,0 +1,4 @@ +source: + github: + owner: anthropics + repository: connect-rust diff --git a/plugins/connectrpc/rust/v0.2.0/.dockerignore b/plugins/connectrpc/rust/v0.2.0/.dockerignore new file mode 100644 index 000000000..5d0f124ff --- /dev/null +++ b/plugins/connectrpc/rust/v0.2.0/.dockerignore @@ -0,0 +1,2 @@ +* +!Dockerfile diff --git a/plugins/connectrpc/rust/v0.2.0/Dockerfile b/plugins/connectrpc/rust/v0.2.0/Dockerfile new file mode 100644 index 000000000..e4f063232 --- /dev/null +++ b/plugins/connectrpc/rust/v0.2.0/Dockerfile @@ -0,0 +1,17 @@ +# syntax=docker/dockerfile:1.19 +FROM rust:1.91.1-alpine3.22 AS builder +RUN apk add --no-cache musl-dev +WORKDIR /app +ENV CARGO_REGISTRIES_CRATES_IO_PROTOCOL=sparse +# The protoc-gen-connect-rust binary is a [[bin]] target in the +# connectrpc-codegen crate. cargo install compiles it by crate name. +RUN --mount=type=cache,target=/usr/local/cargo/registry,sharing=locked --mount=type=cache,target=/root/target \ + cargo install connectrpc-codegen --version 0.2.0 --locked --root /app + +FROM gcr.io/distroless/static-debian12:latest@sha256:87bce11be0af225e4ca761c40babb06d6d559f5767fbf7dc3c47f0f1a466b92c AS base + +FROM scratch +COPY --link --from=base / / +COPY --link --from=builder /app/bin/protoc-gen-connect-rust /protoc-gen-connect-rust +USER nobody +ENTRYPOINT ["/protoc-gen-connect-rust"] diff --git a/plugins/connectrpc/rust/v0.2.0/buf.plugin.yaml b/plugins/connectrpc/rust/v0.2.0/buf.plugin.yaml new file mode 100644 index 000000000..bfe29fea2 --- /dev/null +++ b/plugins/connectrpc/rust/v0.2.0/buf.plugin.yaml @@ -0,0 +1,40 @@ +version: v1 +name: buf.build/connectrpc/rust +plugin_version: v0.2.0 +source_url: https://github.com/anthropics/connect-rust +description: Generates ConnectRPC service traits, typed clients, and monomorphic dispatchers for Rust. Compatible with the Connect, gRPC, and gRPC-Web protocols. Passes the full ConnectRPC conformance suite. +deps: + - plugin: buf.build/community/anthropics-buffa:v0.2.0 +output_languages: + - rust +spdx_license_id: Apache-2.0 +license_url: https://github.com/anthropics/connect-rust/blob/v0.2.0/LICENSE +registry: + cargo: + rust_version: "1.85" + deps: + # ConnectRPC runtime: Router, Context, ConnectError, client transports. + # https://github.com/anthropics/connect-rust/blob/v0.2.0/connectrpc/Cargo.toml + - name: "connectrpc" + req: "0.2.0" + default_features: true + # Generated service stubs use buffa::Message, buffa::view::OwnedView, + # buffa::bytes::Bytes directly. Message types live in the buffa SDK + # crate (via the plugin dep above); this dep is for the runtime API. + - name: "buffa" + req: "0.2.0" + default_features: true + # Streaming method signatures use futures::Stream. + - name: "futures" + req: "0.3" + default_features: true + # Client transport bounds reference http_body::Body. + - name: "http-body" + req: "1" + default_features: true + # The plugin accepts `extern_path=.=` (or the shorthand + # `buffa_module=`) to tell it where the buffa-generated message + # types live. BSR should inject this based on the buffa dep's SDK crate + # name, same as tonic receives extern_path for its prost dep. Leaving + # opts empty here; please advise if an explicit entry is needed. + opts: []