cargo mongodb 2.2.0-beta
v2.2.0-beta

latest releases: 3.1.0, 3.0.1, 3.0.0...
2 years ago

Description

The MongoDB Rust driver team is pleased to announce the v2.2.0-beta release of the mongodb crate.

Highlighted Changes

The following sections detail some of the more important changes included in this release. For a full list of changes, see the Full Release Notes section below.

Change Streams (RUST-521, RUST-74, RUST-522, RUST-1149, RUST-523, RUST-1104)

This release adds support for Change Streams, which allow applications to access real-time data changes without the complexity and risk of tailing the oplog. Applications can use change streams to subscribe to all data changes on a single collection, a database, or an entire deployment, and immediately react to them.

let mut change_stream = coll.watch(None, None).await?;
let coll_ref = coll.clone();
task::spawn(async move {
    coll_ref.insert_one(doc! { "x": 1 }, None).await;
});
while let Some(event) = change_stream.next().await.transpose()? {
    println!("operation performed: {:?}, document: {:?}", event.operation_type, event.full_document);
    // operation performed: Insert, document: Some(Document({"x": Int32(1)}))
}

Raw BSON Incorporation (RUST-1133, RUST-1175)

This release uses the new raw BSON types introduced in v2.2 of the bson crate for internal operations, boosting performance in certain circumstances. It also allows for zero-copy deserialization when working with cursors via the new Cursor::deserialize_current method:

use serde::Deserialize;

#[derive(Debug, Deserialize)]
struct Cat<'a> {
    #[serde(borrow)]
    name: &'a str
}

let coll = db.collection::<Cat>("cat");
let mut cursor = coll.find(None, None).await?;
while cursor.advance().await? {
    println!("{:?}", cursor.deserialize_current()?);
}

MSRV and Dependency Update (RUST-1192, RUST-1220)

This release updates the version of all dependencies used by the Rust driver to their most recent, which required an update of the MSRV to 1.51.

OpenSSL Support (RUST-1083)

This release adds optional support for using OpenSSL for TLS streams via the new openssl-tls feature. Note that rustls is still required as a dependency in this case to avoid breaking backwards compatibility; this will be removed in a future major version release.

Full Release Notes

New Features

Bugfixes

  • minor: derive TypedBuilder for TimeseriesOptions (#557)
  • minor: fix external crate links (#552)
  • RUST-1163 Fix load balancer tests (#576)
  • RUST-812 Reduce flakiness of in_window::load_balancing_test (#568)
  • RUST-1163 Fix load balancer auth tests (#581)

Improvements

Don't miss a new mongodb release

NewReleases is sending notifications on new releases.