pbbson

Crates.iopbbson
lib.rspbbson
version0.1.8
created_at2025-05-09 15:21:28.209567+00
updated_at2025-08-16 20:37:48.553466+00
descriptionUtilities for pbjson to BSON conversion
homepagehttps://megalithic.llc
repositoryhttps://gitlab.com/megalithic-llc/pbbson.git
max_upload_size
id1667215
size10,902,730
David Rauschenbach (drauschenbach)

documentation

README

pbbson-rs

Utilities for pbjson to BSON conversions.

License Arch

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 → String
    • Sensitive
    • 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
Commit count: 0

cargo fmt