#rpc #rpc-framework #stub #generator #generate #protoc #copra

protoc-rust-copra

Code generator works with the copra RPC framework

2 releases

Uses old Rust 2015

0.1.1 Feb 24, 2018
0.1.0 Feb 23, 2018

#27 in #protoc

23 downloads per month

MIT/Apache

19KB
482 lines

Code generator for copra RPC framework

This crate provides one function run, which can generate service provider templates and client side stubs from .proto files. The best place to use this function is the build.rs file. For more information about build.rs, please refer to the build scripts section of the official cargo book.

Examples

Say, we have a awesome.proto file in the project root directory (i.e. next to Cargo.toml), and we want to generate rust code in src/generated. We can add this to build.rs:

extern crate protoc_rust_copra;

fn main() {
    protoc_rust_copra::run(protoc_rust_copra::Args {
        out_dir: "src/generated",
        input: &["awesome.proto"],
        includes: &[],
        rust_protobuf: true
    }).expect("Failed to compile proto files");
}

Acknowledgment

The crate is a mirror of protoc-rust-grpc.

Dependencies

~2.5MB
~44K SLoC