Releases: mongodb/bson-rust
Releases · mongodb/bson-rust
v0.15.0
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.
- Many of the names of our BSON types were inconsistent with the names used by other official
- 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.
- Users have often asked to be able to serialize or deserialize directly to a certain BSON type
- 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.
- The library previously implemented the old version of MongoDB's extended JSON format. We've
- RUST-429 Move encode_document and decode_document into the Document namespace
- Originally, the
encode_document
anddecode_document
were defined as free-floating functions
for parity withserde_json
. However, unlikeserde_json::from_reader
and
serde_json::to_writer
, our functions are not generic, so it makes more sense to derfine them
as methods on theDocument
type.
- Originally, the
- RUST-447 Standardize API with other serde libraries
- To better match terminology used in libraries like
serde_json
, we updated instances of the
termsdecode
andencode
to either useserialize
anddeserialize
or to use terminology
likereader
orwriter
as appropriate.
- To better match terminology used in libraries like
- 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 theOrderedDocument
type. Since the indirection can
cause things like compiler error messages to be a little confusing, we've removed the alias and
changedOrderedDocument
to just be calledDocument
.
- Back when the
- 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
asnon_exhaustive
.
- In order to ensure that adding things like new error variants or new BSON subtypes don't cause
- 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.
- Relying on the underlying format of an ObjectId is a bit of an antipattern, as the specification
- 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.
- See the above explanation for
- 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.
- Our ObjectId generation has been updated to no longer use the machine's hostname, so this error
- RUST-321 Remove Bson::as_*_mut helpers for types that are Copy
- Types like
i32
andbool
that areCopy
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.
- Types like
- RUST-318 Remove Document::insert_bson
Document::insert
is already generic over values that implementInto<String>
and
Into<Bson>
, which includesString
andBson
themselves, so it can be used in any
circumstance whereDocument::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.
- The existing JSON-related methods on the
- 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 thedoc!
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.
- The original implementation of the
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
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
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 featuredecimal128
- Experimental feature, may be replaced by #125 in the future
- #119 Implement
Extend<(String, Bson)>
forOrderedDocument
- #114 Use random byte array instead of
process_id
andmachine_id
(for WASM supports) - #123 Add mutable accessors for Bson variants (
as_*_mut()
) - #124 Uses
std::convert::TryFrom
instead oftry_from
crate
Bug fixed:
- #116 Malformed BSON may trigger large memory allocation. Binary type is limited to maximum length 16MiB.
v0.13.0
v0.12.3
v0.12.2
v0.12.1
v0.12.0
v0.11.1
Release v0.11.0
- Adds
decode_document_utf8_lossy
.