Prost
Protocol Buffers implementation for Rust generating idiomatic structs and encoding helpers.
Official Documentation ↗prost 0.13 / Rust 1.65+. Check the official docs for the latest API surface.Installation
cargo add prostMethods
No methods match this filter.
Overview
Prost implements Protocol Buffers in Rust, providing derives and encoding helpers plus a build integration that turns proto definitions into idiomatic Rust types.
Core Methods
Derive Message on structs annotated with prost attributes, then encode into buffers and decode from bytes. The build crate compiles .proto files into modules you include.
Usage Notes
Keep .proto files as the source of truth, generate at build time, and encode into reused buffers to reduce allocations. Use length-delimited framing when streaming multiple messages.
Common Pitfalls
Reusing or renumbering field tags breaks compatibility with existing data. Recompiling proto types at other than build time causes drift. Decoding untrusted protobuf requires size limits to avoid memory abuse.
Errors
The following points are quoted verbatim from the official documentation. 来源:https://docs.rs/prost/latest/prost/ · 取证方式:HTTP GET 官方 README/文档页(HTML 去标签) · 抓取时间:2026-11-07T13:51:50.451Z. Any error type, throw condition or recovery step not stated there is left unspecified; this page does not infer exception classes or return values.
- I get errors when trying to run cargo test on MacOS If the errors are about missing autoreconf or similar, you can probably fix them by running ⓘ brew install automake brew install libtool Why are most fields are wrapped in an Option ? (https://docs.rs/prost/latest/prost/)
- Unknown Enum Value An error indicating that an unknown enumeration value was encountered. (https://docs.rs/prost/latest/prost/)
Security notes
Quoted verbatim from the official documentation; this is not a complete threat model. 来源:https://docs.rs/prost/latest/prost/ · 取证方式:HTTP GET 官方 README/文档页(HTML 去标签) · 抓取时间:2026-11-07T13:51:50.451Z.
- Bug fixes are still important, and security fixes will be released as soon as possible. (https://docs.rs/prost/latest/prost/)
- Contact the #prost channel in Tokio discord if you feel a bug or security fix is not getting enough attention. (https://docs.rs/prost/latest/prost/)
FAQ
- How is prost different from the official protobuf runtime?
- Prost is a pure-Rust implementation emphasizing idiomatic structs and performance, avoiding a C++ runtime. It integrates with build tooling to generate types from .proto files.
- How do I generate code from .proto files?
- Use prost-build in a build script to compile proto definitions into Rust modules at build time, wired with include! in your source.
- Is protobuf encoding stable across versions?
- The wire format is stable, but field numbers and types must never be reused or changed incompatibly. Add new fields, deprecate old ones, and keep generated types in sync with the schema.
Report a problem with this API docOpens a pre-filled issue on GitHub.