---
name: "tonic-grpc-client-server-rust"
description: "Build high-throughput gRPC services and clients in Rust based on Tower and Hyper."
metadata:
  author: "Hyperium"
  version: "1.0.0"
  runtime_compatibility:
    - "codex"
    - "claude-code"
    - "cursor"
    - "windsurf"
triggers:
  - "compile proto with tonic-build"
  - "implement tonic grpc server"
  - "streaming rpc tonic"
permissions:
  fs_read: true
  fs_write: "workspace"
  shell_exec: false
  net_access: false
---

# Tonic Pure Rust gRPC Server & Client Implementation

Configures Tonic: compiling .proto files in build.rs with tonic-build, implementing generated service traits with #[tonic::async_trait], client stub connections, streaming RPCs (bidirectional streaming), and TLS encryption.

## When to Invoke
Invoke this skill whenever you need to:
- compile proto with tonic-build
- implement tonic grpc server
- streaming rpc tonic

## Execution SOP & Rules
1. Configure build.rs: fn main() -> Result<(), Box<dyn std::error::Error>> { tonic_build::compile_protos('proto/service.proto')?; Ok(()) }.
2. Implement trait: #[tonic::async_trait] impl Greeter for MyGreeter { async fn say_hello(...) -> Result<Response<...>, Status> { ... } }.
3. Start server: Server::builder().add_service(GreeterServer::new(greeter)).serve(addr).await?;
4. Consume from client: let mut client = GreeterClient::connect('http://[::1]:50051').await?;

## Verification Checklist
- Run local linting, syntax validation, and type-checks before reporting completion.
- Ensure all created or modified files adhere to workspace boundaries and avoid uncommitted secrets.
- Verify tests or build commands exit cleanly with return code 0.
