#protoc #proto #path #api #customize #protoc-gen-rust #protoc-gen-run

protoc-rust-no-elision

protoc --rust_out=... available as API. protoc needs to be in $PATH, protoc-gen-run does not.

1 stable release

Uses old Rust 2015

2.0.4 Dec 19, 2018

#5 in #customize

MIT/Apache

7KB
123 lines

API to generate .rs files

API to generate .rs files to be used e. g. from build.rs.

Example code:

extern crate protoc_rust;

protoc_rust::run(protoc_rust::Args {
    out_dir: "src/protos",
    input: &["protos/a.proto", "protos/b.proto"],
    includes: &["protos"],
    customize: Customize {
      ..Default::default()
    },
}).expect("protoc");

And in Cargo.toml:

[build-dependencies]
protoc-rust = "1.5"

Note this API requires protoc command present in $PATH. Although protoc-gen-rust command is not needed.

The alternative is to use pure-rust .proto parser and code generator.

Dependencies

~2MB
~40K SLoC