0PricingLogin
Learn Rust Coding · Lesson

Protobuf and Service Definitions

Describe your API in proto.

Why gRPC and Protobuf

gRPC is a high-performance RPC framework built on HTTP/2 and Protocol Buffers. In Rust, the tonic crate implements gRPC end to end.

Protobuf is the interface definition language (IDL). You describe messages and services once in a .proto file, and code generators produce strongly typed client and server stubs.

Anatomy of a .proto File

Every proto file declares a syntax version and a package. The package namespaces generated types and avoids collisions.

Use proto3 for tonic. The package name maps to a Rust module path after generation.

syntax = "proto3";

package greeter.v1;

All lessons in this course

  1. Protobuf and Service Definitions
  2. Generating Code with tonic-build
  3. Implementing a gRPC Server
  4. Calling from a gRPC Client
← Back to Learn Rust Coding