All Projects → stepancheg → Rust Protobuf

stepancheg / Rust Protobuf

Licence: mit
Rust implementation of Google protocol buffers

Programming Languages

rust
11053 projects

Projects that are alternatives of or similar to Rust Protobuf

javascript-serialization-benchmark
Comparison and benchmark of JavaScript serialization libraries (Protocol Buffer, Avro, BSON, etc.)
Stars: ✭ 54 (-96.99%)
Mutual labels:  serialization, protobuf
Shineframe
高性能超轻量级C++开发库及服务器编程框架
Stars: ✭ 274 (-84.75%)
Mutual labels:  protobuf, serialization
CppSerialization
Performance comparison of the most popular C++ serialization protocols such as Cap'n'Proto, FastBinaryEncoding, Flatbuffers, Protobuf, JSON
Stars: ✭ 89 (-95.05%)
Mutual labels:  serialization, protobuf
kafka-protobuf-serde
Serializer/Deserializer for Kafka to serialize/deserialize Protocol Buffers messages
Stars: ✭ 52 (-97.11%)
Mutual labels:  serialization, protobuf
Cpp Serializers
Benchmark comparing various data serialization libraries (thrift, protobuf etc.) for C++
Stars: ✭ 533 (-70.34%)
Mutual labels:  protobuf, serialization
protoc-plugin
A protoc compiler plugin for Clojure applications
Stars: ✭ 28 (-98.44%)
Mutual labels:  serialization, protobuf
ocaml-pb-plugin
A protoc plugin for generating OCaml code from protobuf (.proto) files.
Stars: ✭ 18 (-99%)
Mutual labels:  serialization, protobuf
Protobuf Java Format
Provide serialization and de-serialization of different formats based on Google’s protobuf Message. Enables overriding the default (byte array) output to text based formats such as XML, JSON and HTML.
Stars: ✭ 134 (-92.54%)
Mutual labels:  protobuf, serialization
Protobuf
A pure Elixir implementation of Google Protobuf
Stars: ✭ 442 (-75.4%)
Mutual labels:  protobuf, serialization
Flatbuffers
FlatBuffers: Memory Efficient Serialization Library
Stars: ✭ 17,180 (+856.04%)
Mutual labels:  protobuf, serialization
elm-protobuf
protobuf plugin for elm
Stars: ✭ 93 (-94.82%)
Mutual labels:  serialization, protobuf
Protobuf Nim
Protobuf implementation in pure Nim that leverages the power of the macro system to not depend on any external tools
Stars: ✭ 90 (-94.99%)
Mutual labels:  protobuf, serialization
veriform
Security-oriented protobuf-like serialization format with "Merkleized" content hashing support
Stars: ✭ 114 (-93.66%)
Mutual labels:  serialization, protobuf
protobuf-d
Protocol Buffers Compiler Plugin and Support Library for D
Stars: ✭ 32 (-98.22%)
Mutual labels:  serialization, protobuf
edap
No description or website provided.
Stars: ✭ 22 (-98.78%)
Mutual labels:  serialization, protobuf
nimpb
Protocol Buffers for Nim
Stars: ✭ 29 (-98.39%)
Mutual labels:  serialization, protobuf
Protostuff
Java serialization library, proto compiler, code generator
Stars: ✭ 1,730 (-3.73%)
Mutual labels:  protobuf, serialization
Ocaml Protoc
A Protobuf Compiler for OCaml
Stars: ✭ 129 (-92.82%)
Mutual labels:  protobuf, serialization
Kotlinx.serialization
Kotlin multiplatform / multi-format serialization
Stars: ✭ 3,550 (+97.55%)
Mutual labels:  protobuf, serialization
Protobuf Convert
Macros for convenient serialization of Rust data structures into/from Protocol Buffers 3
Stars: ✭ 22 (-98.78%)
Mutual labels:  protobuf, serialization

rust-protobuf

GitHub Workflow Status crates.io version License

Protobuf implementation in Rust.

  • Written in pure rust
  • Generate rust code
  • Has runtime library for generated code (Coded{Input|Output}Stream impl)
  • Supports both Protobuf versions 2 and 3

List of crates

rust-protobuf — repository provides multiple crates:

  • protobuf — protobuf runtime
  • protobuf-codegen — protobuf codegen engine and protoc-gen-rust plugin for protoc command
  • protoc — programmatically work with protoc command
  • protoc-rust — codegen which can be invoked programmatically using protoc binary (e. g. from build.rs)
  • protobuf-codegen-pure — pure rust codegen
  • protoc-bin-vendoredprotoc binary packaged as crate, can be used with protoc or protoc-rust crates

About versions and branches

  • 2.*.* is the latest stable version. 2.*.* versions follow semver conventions
  • versions below 2 are no longer supported

See CHANGELOG.md for a list of changes and compatility issues between versions.

How to generate rust code

There are several ways to generate rust code from .proto files:

Generated code

Have a look at generated files, used internally in rust-protobuf:

Rustdoc

docs.rs hosts rustdoc for protobuf.

Getting help

Feel free to open an issue if you need help with rust-protobuf.

Copy-on-write

Rust-protobuf can be used with bytes crate.

To enable Bytes you need to:

  1. Enable with-bytes feature in rust-protobuf:
[dependencies]
protobuf = { version = "2", features = ["with-bytes"] }
  1. Enable bytes option

with Customize when codegen is invoked programmatically:

With stable rust-protobuf:

protoc_rust::run(protoc_rust::Args {
    ...
    customize: Customize {
        carllerche_bytes_for_bytes: Some(true),
        carllerche_bytes_for_string: Some(true),
        ..Default::default()
    },
 });

With rust-protobuf from master:

protoc_rust::Args::new()
    ...
    .customize(Customize {
        carllerche_bytes_for_bytes: Some(true),
        carllerche_bytes_for_string: Some(true),
        ..Default::default()
    })
    .run()?;

or in .proto file:

import "rustproto.proto";

option (rustproto.carllerche_bytes_for_bytes_all) = true;
option (rustproto.carllerche_bytes_for_string_all) = true;

With these options enabled, fields of type bytes or string are generated as Bytes or Chars respectively. When CodedInputStream is constructed from Bytes object, fields of these types get subslices of original Bytes object, instead of being allocated on heap.

serde_derive support

(Only in master, not released yet)

Rust-protobuf can be used with serde.

To enable serde you need to:

  1. Enable serde option

with Customize when codegen is invoked programmatically:

with stable rust-protobuf:

protoc_rust::run(protoc_rust::Args {
    ...
    customize: Customize {
        serde_derive: Some(true),
        ..Default::default()
    },
});

with rust-protobuf from master:

protoc_rust::Args::new()
    ...
    .customize(Customize {
        serde_derive: Some(true),
        ..Default::default()
    })
    .run()?;

or in .proto file:

import "rustproto.proto";

option (rustproto.serde_derive_all) = true;
  1. Make sure to enable the with-serde feature in your Cargo.toml
[features]
default = ["with-serde"]
with-serde = ["protobuf/with-serde"]

You may now Serialize and Deserialize messages:

let my_message = MyMessage::new();
serde_json::to_string(&my_message).unwrap();

Related projects

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].