Prost generates idiomatic Rust types from proto2 and proto3 files and serializes messages without runtime reflection. prost-build integrates codegen into Cargo builds.
Overview
Prost is a Rust implementation focused on compile-time code generation from Protocol Buffer definitions. Generated structs use standard derives, keep comments from .proto files, and map packages to Rust modules.
Compared with some alternatives, it emphasizes readable output, preserves unknown enum values on decode, and supports annotating existing Rust types for protobuf encoding. It does not provide runtime reflection or message descriptors.
Typical adoption adds prost and prost-types to Cargo.toml and uses prost-build in build.rs to compile protos. Recent releases expect a system protoc binary unless generation is configured to skip it.
The ecosystem includes related crates for types and build integration, no_std configuration options, and documentation for serializing hand-written structs. Service stubs can be customized through prost-build generators.
Key features
- proto2 and proto3 codegen
- Derive-based Rust structs
- Comment preservation from protos
- prost-build Cargo integration
- Optional no_std usage
- Custom types via attributes
- Unknown enum value handling
- Package-aware Rust modules
Use cases
- gRPC and RPC message types in Rust
- Binary protocol serialization in services
- Generated models from shared .proto files
- Interop with other protobuf systems
- Build-time schema-driven APIs