January 2019
Intermediate to advanced
520 pages
14h 32m
English
Rust build scripts let you implement a function that will do some additional preparation for project compilation. In our case, we have the ring.proto file with a protocol definition and we want to convert it to Rust sources using the protoc-rust-grpc crate.
Create the build.rs file in the project and add the following content:
extern crate protoc_rust_grpc;fn main() { protoc_rust_grpc::run(protoc_rust_grpc::Args { out_dir: "src", includes: &[], input: &["ring.proto"], rust_protobuf: true, ..Default::default() }).expect("protoc-rust-grpc");}
Build scripts use the main function as an entry point, in which you can implement any activities you want. We used the run function of the protoc-rust-grpc crate with Args—we set ...
Read now
Unlock full access