Skip to content

Releases: mongodb/bson-rust

v0.15.0

03 Jun 01:06
Compare
Choose a tag to compare

Description

The MongoDB Rust Driver team is pleased to announce the first beta of the BSON library, v0.15.0.

Major Changes

In preparation of stabilizing the API of the BSON library, we made a number of breaking changes. The
individual changes are listed below in the release notes, each with a short description of why we
made the change.

Release Notes

Breaking Changes

  • RUST-345 Improve naming of Bson and ElementType cases
    • Many of the names of our BSON types were inconsistent with the names used by other official
      MongoDB libraries. To better integrate with the existing ecosystem around MongoDB, we changed
      the names to match with the other librarires.
  • RUST-319 Convert variants of the BSON enum to use structs instead of multiple fields
    • Users have often asked to be able to serialize or deserialize directly to a certain BSON type
      rather than to a generic BSON value. Previously, the library was inconsistent in terms of which
      BSON types supported direct serialization/deserialization. We standardized this by defining a
      struct for each BSON type variant that previously had more than one field.
  • RUST-346 Update extended JSON format
    • The library previously implemented the old version of MongoDB's extended JSON format. We've
      updated the library to use extended JSON v2, which is the current extended JSON format used by
      all official MongoDB BSON libraries.
  • RUST-429 Move encode_document and decode_document into the Document namespace
    • Originally, the encode_document and decode_document were defined as free-floating functions
      for parity with serde_json. However, unlike serde_json::from_reader and
      serde_json::to_writer, our functions are not generic, so it makes more sense to derfine them
      as methods on the Document type.
  • RUST-447 Standardize API with other serde libraries
    • To better match terminology used in libraries like serde_json, we updated instances of the
      terms decode and encode to either use serialize and deserialize or to use terminology
      like reader or writer as appropriate.
  • RUST-410 Rename OrderedDocument to Document
    • Back when the Document type was originally changed to preserve the order of elements,
      Document was defined as an alias of the OrderedDocument type. Since the indirection can
      cause things like compiler error messages to be a little confusing, we've removed the alias and
      changed OrderedDocument to just be called Document.
  • RUST-313 Mark BSON enums as non-exhaustive where appropriate
    • In order to ensure that adding things like new error variants or new BSON subtypes don't cause
      breaking changes for users who pattern match them, we've marked many of the enums in the library
      as non_exhaustive.
  • RUST-427 Remove decode_document_utf8_lossy
    • decode_document_utf8_lossy was originally provided for parity with the standard library's
      String::from_utf8_lossy, but the BSON specification requires that all strings are encoded in
      UTF-8, so this method isn't particularly useful
  • RUST-315 Remove ObjectId::with_timestamp
    • Relying on the underlying format of an ObjectId is a bit of an antipattern, as the specification
      for how ObjectIds are generated can change (and has done so in the past), and this is not
      considered a breaking change for the BSON library. In particular, it's brittle to rely on the
      timestamp field due to the fact that it relies on the system time of the machine that generates
      the ObjectId; the time could be different across various machines due to time zone, differing
      NTP servers being synced to, or even just the machine being purposely configured to have an
      "incorrect" time. We standardize how ObjectIds are generated to ensure that they'll be unique
      across different machines and different drivers, but there are no user-facing guarantees about
      how they'll be generated. Users who need to perform queries over documents created in a certain
      time range should add a field with the time of insertion (and possibly update that on changes,
      if desired) and use that field when querying. See the documentation for $currentDate for some
      details on how this can be done.
  • RUST-316 Remove timestamp/counter getters on ObjectId
    • See the above explanation for Remove ObjectId::with_timestamp about the brittleness of relying
      on the underlying format of an ObjectId.
  • RUST-317 Remove oid::Error::HostnameError
    • Our ObjectId generation has been updated to no longer use the machine's hostname, so this error
      will never be returned by the library.
  • RUST-321 Remove Bson::as_*_mut helpers for types that are Copy
    • Types like i32 and bool that are Copy don't have a strong need for functionality that
      returns mutable references to them. Users who wish to modify the underlying value of a &mut Bson can still do so without introspecting the value by simply replacing what the reference
      points to.
  • RUST-318 Remove Document::insert_bson
    • Document::insert is already generic over values that implement Into<String> and
      Into<Bson>, which includes String and Bson themselves, so it can be used in any
      circumstance where Document::insert_bson was used.
  • RUST-320 Remove deprecated json methods from Bson
    • The existing JSON-related methods on the Bson type have been deprecated for over three years,
      so we've removed them in preparation of stabilizing the API.
  • RUST-343 Remove old doc! macro syntax
    • The original implementation of the doc! macro was written before Rust allowed macros to use
      the : character. Instead, the syntax => was used for key-value pairs. Rust lifted this
      restriction a few years ago, and the doc! macro was updated to allow the : to be used. In
      preparation of stabilizing the API, we've removed the old syntax, which isn't necessary anymore
      and likely has not been used for new code for a while.

Bug fixes

  • RUST-443 BSON deserializer always ignores unknown fields
  • RUST-457 Fix Display implementation for Bson Binary type

New Features

  • RUST-311 Support decoding Undefined / MinKey / MaxKey / DbPointer
  • RUST-390 Implement ordering for TimeStamp
  • RUST-445 Decimal128 round tripping

Improvement

  • RUST-217 Rephrase unsupported/corrupt BSON messages
  • RUST-312 Remove implementation of Error::description in BSON library
  • RUST-314 Remove constants for subtypes and element types
  • RUST-430 Label BSON error enum cases
  • RUST-437 Add documentation for BSON library error variants
  • RUST-438 Add more detailed examples to BSON library documentation
  • RUST-444 Replace unneeded serde enum cases in DecoderError

v0.14.1

17 Mar 17:13
Compare
Choose a tag to compare

Description

The MongoDB Rust driver team is pleased to announce a new bugfix release of the BSON library, v0.14.1.

Release Notes

Bug fixes

  • RUST-305 Fix deserialization of non-generic binary

New features

  • #130 More Bson From<> implementations

Improvements

  • #131 Clean macro imports

Contributors

Thanks to @jcdyer for the pull requests!

v0.14.0

31 Aug 13:40
Compare
Choose a tag to compare

Language features updates:

  • Rust Edition 2018
  • Uses dyn keyword for Trait objects.

New features:

  • #118 Add Decimal128 supports with decimal crate, could be enabled by feature decimal128
    • Experimental feature, may be replaced by #125 in the future
  • #119 Implement Extend<(String, Bson)> for OrderedDocument
  • #114 Use random byte array instead of process_id and machine_id (for WASM supports)
  • #123 Add mutable accessors for Bson variants (as_*_mut())
  • #124 Uses std::convert::TryFrom instead of try_from crate

Bug fixed:

  • #116 Malformed BSON may trigger large memory allocation. Binary type is limited to maximum length 16MiB.

v0.13.0

11 Aug 16:26
Compare
Choose a tag to compare
  • [BUG-FIXED] #103 Proper implementation of Newtype serialization in serde. Maybe a breaking change.

v0.12.3

30 Jul 16:29
Compare
Choose a tag to compare
  • #102 #100 Optimizations. The most important improvement is to remove unnecessary to_owned()/clone()/to_string() allocations.
  • [BREAKING] (MAYBE) Implements From<UtcDateTime> for DateTime<Utc> instead of Into<DateTime<Utc> for UtcDateTime.

v0.12.2

11 Jul 16:14
Compare
Choose a tag to compare
  • #99 - Implement TimeStamp serde serialisation
  • #98 - Fixed incorrect endianness for TimeStamp
  • #95 - Add i2u feature to allow auto converting between signed and unsigned integers.

v0.12.1

03 Jul 16:35
Compare
Choose a tag to compare
  • #64 Won't panic if timestamp is nagative (which is impossible in real life).

v0.12.0

03 Jul 16:11
Compare
Choose a tag to compare
  • #89 Implemented special serialization/deserialization rules for bytes array in serde.
  • #64 Won't crash if the length of UTF-8 string is invalid.
  • Updated dependencies.

v0.11.1

23 Feb 06:35
Compare
Choose a tag to compare
  • #88 Add TimeStamp facilities for de/serialize Timestamp value.

Release v0.11.0

05 Jan 22:56
Compare
Choose a tag to compare
  • Adds decode_document_utf8_lossy.