[][src]Crate pb_jelly_gen

pb_gen generates Rust bindings for proto2 and proto3 files. It's intended to be used with pb_rs.

Examples

Complete examples can be found in the examples crate, or the pb-test crate of the protobuf_rs workspace.

In a nutshell 🥜

You can include pb_gen in your Cargo project, by including it as a [build-dependency] in your Cargo.toml

[build-dependencies]
pb-gen = "0.1"

Then from a build.rs script, use either the GenProtos builder struct, or the gen_protos convience function to specify where your protos live, and where the generated code should be put.

use pb_jelly_gen::GenProtos;
 
fn main() -> std::io::Result<()> {
   GenProtos::builder()
       // output path for our generated code
       .out_path("./gen")
       // directory where our protos live
       .src_path("./protos")
       // delete and recreate the `out_path` directory every time
       .cleanup_out_path(true)
       .gen_protos();

   Ok(())
}

Structs

GenProtos

A builder struct to configure the way your protos are generated, create one with GenProtos::builder()

Functions

gen_protos

A "no frills" way to generate Rust bindings for your proto files. src_paths is a list of paths to your .proto files, or the directories that contain them. Generated code it outputted to <current crate's manifest>/gen.