Crates.io | protoc-rust |
lib.rs | protoc-rust |
version | 2.28.0 |
source | src |
created_at | 2017-06-12 09:32:17.653233 |
updated_at | 2022-09-26 00:53:21.974019 |
description | protoc --rust_out=... available as API. protoc needs to be in $PATH, protoc-gen-run does not. |
homepage | https://github.com/stepancheg/rust-protobuf/ |
repository | https://github.com/stepancheg/rust-protobuf/ |
max_upload_size | |
id | 18691 |
size | 14,384 |
.rs
files using protoc
to parse filesThis API requires protoc
command present in $PATH
or explicitly passed to Codegen
object
(but protoc
plugin is not needed).
extern crate protoc_rust;
fn main() {
protoc_rust::Codegen::new()
.out_dir("src/protos")
.inputs(&["protos/a.proto", "protos/b.proto"])
.include("protos")
.run()
.expect("Running protoc failed.");
}
and in build.rs
:
[build-dependencies]
protoc-rust = "2"
It is advisable that protoc-rust
build-dependency version be the same as
protobuf
dependency.
The alternative is to use
protobuf-codegen-pure
crate.
This crate searches for protoc
binary in $PATH
by default.
protoc
binary can be obtained using
protoc-bin-vendored
crate
and supplied to Codegen
object.
In branch 3 of rust-protobuf this functionality is provided by
protobuf-codegen
crate.