12 releases
| 0.2.2 | Dec 25, 2025 |
|---|---|
| 0.2.1 | Nov 14, 2025 |
| 0.1.9 | Sep 6, 2025 |
| 0.1.8 | Aug 16, 2025 |
| 0.1.4 | May 23, 2025 |
#671 in Encoding
437 downloads per month
Used in saas-rs-sdk
625KB
377 lines
pbbson-rs
Utilities for pbjson to BSON conversions.
Installing
$ cargo add pbbson
Testing
$ make check
Using
Convert a Prost Protobuf message into a BSON Document
use bson::Document;
use pbbson::Model;
let doc: Document = Model::try_from(&message).unwrap().into();
Convert a BSON Document into a Prost Protobuf message
let my_struct: StructType = model.try_into().unwrap();
Status
Protobuf to BSON
- bool → Bool
- double → Double
- int32 → Int32
- int64 → Int64
- repeated → List
- string → String
- uint32 → Int64
- uint64 → String
- pbjson types
- Any
- Api
- Descriptor
- Duration → String (Go-style duration string with humanized suffixes)
- Empty
- FieldMask
- SourceContext
- Struct → Document
- Timestamp → DateTime
- Type
- Wrappers
BSON to Protobuf
- Array
- Binary
- Encrypted
- Function
- Generic
- Md5 → bytes
- Md5 → String
- Sensitive
- Uuid → bytes
- Uuid → String
- Boolean
- DateTime → Timestamp
- Decimal128
- Document → Struct
- Double
- Int32
- Int64
- JavaScriptCode
- JavaScriptCodeWithScope
- Null
- ObjectId → String (20-byte base32hex encoded xid)
- RegularExpression
- String → Duration
- String → String
- String → Timestamp
- Timestamp
Dependencies
~16–25MB
~373K SLoC