7个版本

0.2.0 2024年3月15日
0.1.4 2023年10月4日
0.1.3 2023年9月21日
0.0.3 2023年9月14日
0.0.2 2023年8月9日

#26 in #tonic

Download history 2/week @ 2024-04-04 2/week @ 2024-05-30

266 每月下载量

MIT 协议

205KB
5K SLoC

Protokit

crates.io img example workflow

Rust的协议缓冲区实现。

为什么不使用 prost/pb-j/rust-protobuf?

始于我对适当 textformat 支持的需求。

any_value {
  [type.googleapis.com/com.example.SomeType] {
    field1: "hello"
  }
}

在调查了其他crate之后,我发现它们存在其他问题(rust-protobuf需要装箱,prost的代码生成很混乱)。

功能

  • 二进制(100% 兼容)+ 文本(90% 兼容)格式支持
  • 无需消息装箱
  • GRPC(可与tonic一起使用)
  • 创建消息实现的好用的derive宏,无需proto编译器
#[derive(Default, Debug, Clone, BinProto)]
pub struct FieldPath {
    #[field(1, varint, packed)]
    pub fields: Vec<u32>,
}

#[derive(Default, Debug, Clone, BinProto)]
pub struct FieldMask {
    #[field(1, nested, repeated)]
    pub paths: Vec<FieldPath>,
}

依赖关系

~5–13MB
~149K SLoC