build prost struct with msg id so as to realize type judgment * examples
protobuf
message Fail{
enum MsgId { None=0;Id = 150002; }
int64 number=1;
string message=2;
}
```rust
pub struct Fail { #[prost(int64, tag = "1")] pub number: i64, #[prost(string, tag = "2")] pub message: ::prost::alloc::string::String, }
pub const FAILID: i32 = Fail::getmsg_id();
impl Fail { #[allow(deadcode)] pub const fn getmsg_id() -> i32 { 150002 } }
impl ::prostmsgid::MsgId for Fail { fn getmsgid(&self) -> i32 { Self::getmsgid() } }
///get all msg type id
pub const fn msg_ids()->&'static [i32]{ &[ 150002, //.RunTT.Fail ] } ```
prost-build
prost-build
prost-build
makes it easy to generate Rust code from .proto
files as part of
a Cargo build. See the crate documentation for examples
of how to integrate prost-build
into a Cargo project.
protoc
prost-build
uses protoc
to parse the proto files. There are two ways to make protoc
available for prost-build
:
protoc
in your PATH
. This can be done by following the [protoc
install instructions].PROTOC=<my/path/to/protoc>
environment variable with the path to
protoc
.prost-build
is distributed under the terms of the Apache License (Version 2.0).
See LICENSE for details.
Copyright 2017 Dan Burkert