Uploaded image for project: 'Rust Driver'
  1. Rust Driver
  2. RUST-1985

Revisit serde representations of bson types

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Unknown Unknown
    • bson-3.0.0
    • Affects Version/s: None
    • Component/s: None
    • None
    • Rust Drivers

      (For backstory, see https://github.com/mongodb/bson-rust/pull/479)

      Right now, the types provided by the bson crate will serialize to human-readable destinations in extjson format. This is convenient because it gave us a ready-made list of representations and because if a bson type or user type embedding bson is serialized to json, it Just Works.

      However, this has turned out to have some major issues:

      • It's inefficient; for values backed by byte buffers we jump through a lot of hoops to make this work.
      • It's lossy; extjson does not provide precise representations for various values, so serializing a document into a document can lose precision.
      • It's hard to maintain; using extjson as internal representation means the number of places that need to parse or emit that internally has proliferated and are hard to adjust or fix.

      As an alternative, we could explicitly document that the Serde representation of bson types is not guaranteed to be anything in particular, just that future releases will parse values emitted by older versions. This would allow substantial code simplification, efficiency, and precision, and users that actually need extjson could use the already-provided explicit conversion functions (as Serde annotations or otherwise).

            Assignee:
            Unassigned Unassigned
            Reporter:
            abraham.egnor@mongodb.com Abraham Egnor
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: