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
- RUST-521 Implement naive streaming and resume token caching for change streams (#531)
- RUST-1133 Update driver to use the raw BSON API (#546)
- RUST-74 Add cluster_time to ChangeStreamEvent (#548)
- RUST-522 Implement resume functionality for change streams (#547)
- RUST-1149 Prose tests for change streams. (#561)
- RUST-523 Support change streams in unified spec tests (#564)
- RUST-1104 sync wrapper for the change stream API (#566)
- RUST-1106 Make the change streams API visible (#571)
- RUST-43 Add change streams examples for documentation (#572)
- RUST-1138 Add bson-serde_with feature flag (#580)
- RUST-1175 Support zero-copy deserialization from cursors (#579)
- RUST-995 Add tokio-sync feature flag (#578)
- RUST-1083 Add openssl as an optional TLS provider (#590)
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
- RUST-1088 Always specify error labels at the top level (#553)
- RUST-894 Unskip write_error::details test on sharded clusters (#526)
- RUST-395 Log skipped tests (#523)
- RUST-1143 Bump max wire version to 15 (#573)
- RUST-1077 Update read/write concern document tests (#567)
- RUST-1173 Replace "Versioned API" references with "Stable API" (#585)
- RUST-1192 Bump MSRV to 1.49.0 (#584)
- RUST-1207 Bump zstd to v0.10 (#588) (thanks @moy2010!)
- RUST-1220 Bump outdated dependencies (#596)
- RUST-886 Use lossy UTF-8 decoding for responses to insert and update commands (#601)
- RUST-803 Conditionally use hello for monitoring (#600)
- RUST-1064 Retry on handshake failure (#598)