8个版本

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日

#3 in #boxing


3 个crate中使用

MIT 协议

175KB
4.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一起使用)
  • 创建消息实现时无需proto编译器的优雅 derive 宏
#[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>,
}

依赖项

~6MB
~100K SLoC