#protobuf #serialization #codegen #buffer #protocols #protoc #generate

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

#2115 in Encoding

Download history 28/week @ 2024-06-16 19/week @ 2024-06-23 16/week @ 2024-06-30 36/week @ 2024-07-07 42/week @ 2024-07-14 38/week @ 2024-07-21 116/week @ 2024-07-28 23/week @ 2024-08-04 55/week @ 2024-08-11 47/week @ 2024-08-18 36/week @ 2024-08-25 23/week @ 2024-09-01 64/week @ 2024-09-08 24/week @ 2024-09-15 54/week @ 2024-09-22 28/week @ 2024-09-29

173 downloads per month

MIT license

1.5MB
38K 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