#build #prost #proto3 #result #package #path #enums #generator #msg

prost-msg-build

A Protocol Buffers implementation for the Rust Language

5 releases

0.2.0 Mar 23, 2023
0.1.6 Jan 6, 2023
0.1.5 May 12, 2022
0.1.4 Apr 22, 2022

#996 in Encoding

Download history 17/week @ 2023-10-29 5/week @ 2023-11-05 4/week @ 2023-11-12 13/week @ 2023-11-19 31/week @ 2023-11-26 18/week @ 2023-12-03 12/week @ 2023-12-10 4/week @ 2023-12-17 24/week @ 2023-12-24 2/week @ 2023-12-31 4/week @ 2024-01-07 3/week @ 2024-01-14 9/week @ 2024-01-21 18/week @ 2024-01-28 3/week @ 2024-02-04 30/week @ 2024-02-11

60 downloads per month

Apache-2.0

155KB
3K SLoC

Documentation Crate

prost-msg-build

build prost struct with msg id so as to realize type judgment

message Fail{
   enum MsgId {  None=0;Id = 150002; }
   int64 number=1;
   string message=2;
}

auto impl MsgId and const fn

#[derive(Clone, PartialEq, ::prost::Message)]
pub struct Fail {
    #[prost(int64, tag = "1")]
    pub number: i64,
    #[prost(string, tag = "2")]
    pub message: ::prost::alloc::string::String,
}

#[allow(dead_code)]
pub const FAIL_ID: i32 = Fail::get_msg_id();

impl Fail {
    #[allow(dead_code)]
    pub const fn get_msg_id() -> i32 {
        150002
    }
}

impl ::prost_msg_id::MsgId for Fail {
    fn get_msg_id(&self) -> i32 {
        Self::get_msg_id()
    }
}

///get all msg type id
#[allow(dead_code)]
pub const fn msg_ids()->&'static [i32]{
    &[
        150002, //.RunTT.Fail
    ]
}

about 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:

  • Include protoc in your PATH. This can be done by following the protoc install instructions.
  • Pass the PROTOC=<my/path/to/protoc> environment variable with the path to protoc.

License

prost-build is distributed under the terms of the Apache License (Version 2.0).

See LICENSE for details.

Copyright 2017 Dan Burkert

Dependencies

~8–20MB
~271K SLoC