File: README.md

package info (click to toggle)
rust-protoc-rust 2.27.1-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid
  • size: 100 kB
  • sloc: makefile: 4
file content (48 lines) | stat: -rw-r--r-- 1,172 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<!-- cargo-sync-readme start -->

# API to generate `.rs` files using `protoc` to parse files

This API requires `protoc` command present in `$PATH`
or explicitly passed to `Codegen` object
(but `protoc` *plugin* is not needed).

```rust
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`:

```toml
[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](https://docs.rs/protobuf-codegen-pure).

# Protoc binary

This crate searches for `protoc` binary in `$PATH` by default.

`protoc` binary can be obtained using
[`protoc-bin-vendored` crate](https://docs.rs/protoc-bin-vendored)
and supplied to `Codegen` object.

# This is version 2

In branch 3 of rust-protobuf this functionality is provided by
[`protobuf-codegen` crate](https://docs.rs/protobuf-codegen/%3E=3.0.0-alpha).

<!-- cargo-sync-readme end -->