protobuf

A pure Rust implementation of Google Protocol Buffers with runtime support for generated code.

Library
Cargo
v4.36.0-rc.2
2,973stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
42/100Fair
Development Activity0
Maintenance0
Community68
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
73/100Good
Architecture82
Code Quality80
Innovation70
Learning Curve60

protobuf is a pure-Rust implementation of Google’s Protocol Buffers, the language-neutral binary serialization format. It provides the runtime library that generated Rust code depends on, including coded input/output streams, the Message trait, and reflection support, and works with both proto2 and proto3 syntax.

The crate is the runtime half of the rust-protobuf project (paired with protobuf-codegen for code generation) and has been a long-standing default for Protocol Buffers in the Rust ecosystem, with over 160 million downloads.

What You Get

  • A runtime library implementing the Protocol Buffers wire format via CodedInputStream and CodedOutputStream
  • The Message trait and supporting types that generated Rust code implements and calls
  • Support for both proto2 and proto3 syntax, including enums, oneofs, and well-known types
  • Runtime reflection through descriptors for dynamic message inspection and manipulation
  • An optional with-bytes feature for zero-copy field access using the bytes crate

Common Use Cases

  • Serializing and deserializing Protocol Buffers messages in Rust services and clients
  • Providing the runtime for .proto-generated Rust code produced by protobuf-codegen
  • Interoperating with other languages over a shared protobuf schema
  • Inspecting or building messages dynamically at runtime via reflection

Under The Hood

Architecture - protobuf is the runtime crate within the larger rust-protobuf Cargo workspace (alongside protobuf-codegen, protobuf-parse, protobuf-json-mapping, and protobuf-support). Its src tree implements the wire format in coded_input_stream/coded_output_stream, the core Message and reflection abstractions, enum and oneof handling (enum_or_unknown.rs, enums.rs), cached sizing, and the generated descriptor types that back reflection.

Tech Stack - Pure Rust (edition 2021) with a deliberately small dependency set: thiserror for errors, once_cell for lazy statics, an optional bytes dependency for the with-bytes feature, and the sibling protobuf-support crate. A build.rs handles version-gated generation concerns.

Code Quality - The project is mature and heavily exercised, with an extensive workspace of test crates (test-crates/, protobuf-examples/) validating generated-code behavior against real .proto definitions and a long changelog history. Note the README states the implementation is approaching end of life as an official Google-backed Rust protobuf implementation matures, though this crate remains widely used.

API Design - The public API centers on the Message trait plus parse_from_bytes/write_to_bytes helpers, so day-to-day use is straightforward once code is generated. Reflection and the codegen split add surface area, and the proto2/proto3 distinctions plus the separate codegen step give it a moderate learning curve for newcomers.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search