Comparison: connectrpc-axum vs connectrpc
Overview
connectrpc is a Rust implementation of the Connect protocol that provides both client and server components. It includes a Reqwest-based client and an Axum server implementation, with code generation for both. The project is in early development with streaming support being actively developed.
Feature Comparison
| Feature | connectrpc-axum | connectrpc |
|---|---|---|
| Unary RPC (POST) | ✅ | ✅ |
| Unary RPC (GET) | ✅ | ✅ |
| Server streaming | ✅ | ✅ |
| Client streaming | ✅ | ✅ |
| Bidirectional streaming | ✅ | Planned |
| JSON encoding | ✅ | ✅ |
| Protobuf encoding | ✅ | ✅ |
| Compression (gzip) | ✅ | ❌ |
| Timeouts | ✅ | ✅ |
| Error details | ✅ | ✅ |
| Message size limits | ✅ | ❌ |
| Tonic/gRPC interop | ✅ | ❌ |
| gRPC-Web | ✅ | ❌ |
| Generated client | ❌ | ✅ (Reqwest) |
API Comparison
connectrpc-axum:
async fn say_hello(
ConnectRequest(req): ConnectRequest<HelloRequest>,
) -> Result<ConnectResponse<HelloResponse>, ConnectError> {
Ok(ConnectResponse::new(HelloResponse {
message: format!("Hello, {}!", req.name.unwrap_or_default()),
}))
}
HelloWorldServiceBuilder::new()
.say_hello(say_hello)
.build_connect()connectrpc:
async fn say_hello(
state: State,
req: UnaryRequest<HelloRequest>,
) -> Result<UnaryResponse<HelloResponse>> {
Ok(UnaryResponse::new(HelloResponse {
message: format!("Hello, {}!", req.into_message().name.unwrap_or_default()),
}))
}
HelloWorldServiceAxumServer {
state: my_state,
say_hello,
}.into_router()Key Technical Differences
Architecture: connectrpc-axum uses middleware (
ConnectLayer) and Axum extractors for protocol handling, while connectrpc parses requests inline within handler trait implementations.State handling: connectrpc-axum leverages Axum's native state management via
State<T>extractor. connectrpc requires state to be passed explicitly as a field on the generated server struct.Client generation: connectrpc generates Reqwest-based clients (Proto and JSON variants) at build time. connectrpc-axum is server-only and relies on existing Connect clients.
gRPC support: connectrpc-axum provides
ContentTypeSwitchfor routing between Connect and gRPC (Tonic) services. connectrpc is Connect-only with no gRPC interop.Code output: connectrpc writes generated code to user-specified files (e.g.,
src/lib.rs). connectrpc-axum generates toOUT_DIRand usesinclude!macros.
Summary
| connectrpc-axum strengths | connectrpc strengths |
|---|---|
| Full streaming support (including bidi) | Generated Reqwest client |
| Compression support | Flexible output file placement |
| Tonic/gRPC interop | Simpler standalone library |
| Message size limits | Combined client+server in one crate |
| Idiomatic Axum extractors | - |