expression
gRPC: four RPC message directions
Unary exchanges have one message in each direction; server streaming sends multiple responses, client streaming sends multiple requests, and bidirectional streaming supports both. The labels model permitted directions, not transport behavior or exact message counts for a failed call. Expected stdout (not executed): unary: one -> one server streaming: one -> stream client streaming: stream -> one bidirectional: stream -> stream Common mistake: Assuming every stream produces at least one message, or that bidirectional calls require alternating sends.
Formal Syntax & Structure
rust syntaxrust
rpc Method(stream Input) returns (stream Output);Working Example
Example Snippetrust
fn main() { for (name, client, server) in [ ("unary", false, false), ("server streaming", false, true), ("client streaming", true, false), ("bidirectional", true, true), ] { let label = |many| if many { "stream" } else { "one" }; println!("{name}: {} -> {}", label(client), label(server)); }}