Expand description
API to generate .rs files for ttrpc from protobuf
use ttrpc_codegen::{Customize, Codegen, ProtobufCustomize};
fn main() {
let protobuf_customized = ProtobufCustomize::default().gen_mod_rs(false);
Codegen::new()
.out_dir("protocols/asynchronous")
.inputs(&protos)
.include("protocols/protos")
.rust_protobuf()
.customize(Customize {
async_all: true,
..Default::default()
})
.rust_protobuf_customize(protobuf_customized.clone())
.run()
.expect("Gen async code failed.");
}
If there’s no out_dir and use ‘gen_mod’ feature You can use the following method to include the target file include!(concat!(env!(“OUT_DIR”), “/mod.rs”));
Structs§
- Invoke pure rust codegen.
- Customize generated code.
- Specifies style of generated code. Generated files can be customized using this proto or using
rustproto.proto
options.
Traits§
- Dynamic callback to customize code generation.