#protobuf #serialization #codegen #protoc #buffer #proto #protocols

bin+lib protobuf-codegen-pure3

Pure-rust codegen for protobuf using protobuf-parser crate WIP

4 stable releases

Uses old Rust 2015

2.28.2 Feb 27, 2023
2.28.1 Oct 14, 2022
2.27.3 Sep 7, 2022

#1726 in Encoding

Download history 82/week @ 2023-12-15 73/week @ 2023-12-22 73/week @ 2023-12-29 58/week @ 2024-01-05 158/week @ 2024-01-12 156/week @ 2024-01-19 110/week @ 2024-01-26 169/week @ 2024-02-02 30/week @ 2024-02-09 90/week @ 2024-02-16 128/week @ 2024-02-23 87/week @ 2024-03-01 116/week @ 2024-03-08 73/week @ 2024-03-15 58/week @ 2024-03-22 33/week @ 2024-03-29

288 downloads per month

MIT license

1.5MB
37K SLoC

API to generate .rs files

This API does not require protoc command present in $PATH.

extern crate protoc_rust;

fn main() {
    protobuf_codegen_pure::Codegen::new()
        .out_dir("src/protos")
        .inputs(&["protos/a.proto", "protos/b.proto"])
        .include("protos")
        .run()
        .expect("Codegen failed.");
}

And in Cargo.toml:

[build-dependencies]
protobuf-codegen-pure = "2"

It is advisable that protobuf-codegen-pure build-dependecy version be the same as protobuf dependency.

The alternative is to use protoc-rust crate which uses protoc command for parsing (so it uses the same parser Google is using in their protobuf implementations).

Version 2

This is documentation for version 2 of the crate.

In version 3, this API is moved to protobuf-codegen crate.


lib.rs:

API to generate .rs files

This API does not require protoc command present in $PATH.

extern crate protoc_rust;

fn main() {
    protobuf_codegen_pure::Codegen::new()
        .out_dir("src/protos")
        .inputs(&["protos/a.proto", "protos/b.proto"])
        .include("protos")
        .run()
        .expect("Codegen failed.");
}

And in Cargo.toml:

[build-dependencies]
protobuf-codegen-pure = "2"

It is advisable that protobuf-codegen-pure build-dependecy version be the same as protobuf dependency.

The alternative is to use protoc-rust crate which uses protoc command for parsing (so it uses the same parser Google is using in their protobuf implementations).

Version 2

This is documentation for version 2 of the crate.

In version 3, this API is moved to protobuf-codegen crate.

Dependencies