quick-protobuf
A pure Rust library to deserialize protobuf files.
Simple codegen. No need of protoc. Fast.
Getting started
-
Convert your .proto files into rust modules using included pb-rs crate
# generate a /my/proto/path/my_file.rs module to import into your project
-
Import quick-protobuf into you crate
# Cargo.toml [] = { = "https://github.com/tafia/quick-protobuf" }
-
Use the generated module
// main.rs or lib.rs extern crate quick_protobuf; // generated with protorust_codegen use Write; use ; use Foo;
Objectives
This library is an alternative to the widely used rust-protobuf.
-
Pros
- No need to install anything on your machine but rust
- No trait objects: faster/simpler parser
- Dead simple generated modules:
- a struct with public fields
- an implementation of Message(Read/Write), which means just one match loop for reader
- more than 10x smaller modules in practice
- modifying the generated code if needed while not necessarily advised is totally fine as the code is easy to reason about
- Easier on memory (no trait objects, no storage of unknown fields)
-
Cons
- Very immature library at the moment: many missing functionalities, very poor test coverage, very poor documentation
- Not a drop-in replacement of [rust-protobuf], in particular, you have to handle
Option
s unwrapping yourself - probably many other corner cases I overlooked
Benchmarks
The only implemented benchmarks are the adaptation from rust-protobuf perftest.