github mongodb/mongo-rust-driver v2.0.0-alpha.1

latest releases: v1.2.5, v2.1.0, v2.1.0-beta...
pre-release3 years ago

Description

The MongoDB Rust driver team is pleased to announce the v2.0.0-alpha.1 release of the driver. This is the second alpha release in preparation for the 2.0 version of the driver, and it contains a number of breaking changes, new features, and bug fixes.

This release also contains all of the changes that were included in v1.2.0 but not in v2.0.0-alpha. Check out the release notes for v1.2.0 for more information.

Note: this release also updates the MSRV to 1.47

Release Notes

Breaking Changes

Document no longer the default generic type for Collection and Cursor (RUST-735)

The generic parameter must now always explicitly specified when referring to these types. Additionally, the Database::collection and Database::collection_with_options helpers now require a generic parameter to be specified as well. This was done to ease and promote the use of serde with the driver. As part of this, Database::collection_with_type was removed as it was no longer necessary.

// old
let collection = db.collection("foo");
let typed_collection = db.collection_with_type::<MySerdeType>("foo");
struct C { cursor: Cursor }
struct Tc { cursor: Cursor<MySerdeType> }

// new
let collection = db.collection::<Document>("foo");
let typed_collection = db.collection::<MySerdeType>("foo");
struct C { cursor: Cursor<Document> }
struct Tc { cursor: Cursor<MySerdeType> }

Improved Error Matching (RUST-679)

The error API was updated to allow for easier matching by removing the Arc wrapper around Error::kind. Instead, the Arc was moved into the cases that did not implement Clone.

// old
match e.kind.as_ref() {
    ErrorKind::Io(e) => todo!(),
    _ => todo!()
}

// new
match e.kind {
    ErrorKind::Io(e) => todo!(),
    _ => todo!()
}

New Features

  • RUST-52 Drivers sessions API
  • RUST-735 Collection helpers return Collection<T> (breaking)

Improvements

  • RUST-679 Simplify error API to ease pattern matching (breaking)
  • RUST-719 Correct casing in ServerType variants (breaking)
  • RUST-705 Switch from err-derive to thiserror
  • RUST-658 Change estimated_document_count() to use the $collStats aggregation stage

Bug Fixes

  • RUST-714 Deadlock possible during retry
  • RUST-675 Server selection fails despite having a selectable server
  • RUST-717 Hint should be in deletes array for command, not in top-level document
  • RUST-718 Enforce update versus replace semantics
  • RUST-728 Inherit Collection options in find method

Don't miss a new mongo-rust-driver release

NewReleases is sending notifications on new releases.