[][src]Function exonum_build::protobuf_generate

pub fn protobuf_generate<P, R, I, T>(
    input_dir: P,
    includes: I,
    mod_file_name: T
) where
    P: AsRef<Path>,
    R: AsRef<Path>,
    I: IntoIterator<Item = R>,
    T: AsRef<str>, 

Generates .rs files from .proto files.

protoc executable from protobuf should be in $PATH

Examples

In build.rs

extern crate exonum_build;

use exonum_build::protobuf_generate;

// Includes usually should contain input_dir.
protobuf_generate("src/proto", &["src/proto"], "example_mod.rs")

After successful run $OUT_DIR will contain *.rs for each *.proto file in "src/proto/**/" and example_mod.rs which will include all generated .rs files as submodules.

To use generated protobuf structs.

In src/proto/mod.rs

This example is not tested
extern crate exonum;

include!(concat!(env!("OUT_DIR"), "/example_mod.rs"));

// If you use types from `exonum` .proto files.
use exonum::proto::schema::*;