Skip to content

Commit a82265d

Browse files
authored
RUST-2217 Optionally support bson crate 3.0 (#1380)
1 parent c62b174 commit a82265d

File tree

169 files changed

+428
-370
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

169 files changed

+428
-370
lines changed

.evergreen/aws-lambda-test/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ To deploy the application, you need the folllowing tools:
3333

3434
* SAM CLI - [Install the SAM CLI](https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/serverless-sam-cli-install.html)
3535
* Docker - [Install Docker community edition](https://hub.docker.com/search/?type=edition&offering=community)
36-
* [Rust](https://www.rust-lang.org/) version 1.74.0 or newer
36+
* [Rust](https://www.rust-lang.org/) version 1.81.0 or newer
3737
* [cargo-lambda](https://github.com/cargo-lambda/cargo-lambda) for cross-compilation
3838

3939
To build and deploy your application for the first time, run the following in your shell:

.evergreen/compile-only.sh

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,6 @@ source ./.evergreen/env.sh
99
if [ "$RUST_VERSION" != "" ]; then
1010
rustup toolchain install $RUST_VERSION
1111
TOOLCHAIN="+${RUST_VERSION}"
12-
# Remove the local git dependencies for bson and mongocrypt, which don't work properly with the MSRV resolver.
13-
sed -i "s/bson =.*/bson = \"2\"/" Cargo.toml
14-
sed -i "s/mongocrypt =.*/mongocrypt = { version = \"0.2\", optional = true }/" Cargo.toml
1512
CARGO_RESOLVER_INCOMPATIBLE_RUST_VERSIONS=fallback cargo +nightly -Zmsrv-policy generate-lockfile
1613
fi
1714

@@ -22,4 +19,4 @@ cargo $TOOLCHAIN build
2219
cargo $TOOLCHAIN build --all-features
2320

2421
# Test with no default features.
25-
cargo $TOOLCHAIN build --no-default-features --features compat-3-0-0,rustls-tls
22+
cargo $TOOLCHAIN build --no-default-features --features compat-3-3-0,bson-3,rustls-tls

.evergreen/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -795,7 +795,7 @@ tasks:
795795
- func: "compile only"
796796
vars:
797797
# Our minimum supported Rust version. This should be updated whenever the MSRV is bumped.
798-
RUST_VERSION: 1.74.0
798+
RUST_VERSION: 1.81.0
799799

800800
- name: check-cargo-deny
801801
commands:

Cargo.lock

Lines changed: 31 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ license = "Apache-2.0"
1717
readme = "README.md"
1818
name = "mongodb"
1919
version = "3.2.3"
20-
rust-version = "1.74"
20+
rust-version = "1.81"
2121

2222
exclude = [
2323
"etc/**",
@@ -30,7 +30,10 @@ exclude = [
3030

3131
[features]
3232
default = ["compat-3-0-0", "rustls-tls", "dns-resolver"]
33-
compat-3-0-0 = []
33+
compat-3-0-0 = ["compat-3-3-0", "bson-2"]
34+
compat-3-3-0 = []
35+
bson-2 = ["dep:bson2", "mongocrypt/bson-2"]
36+
bson-3 = ["dep:bson3", "mongocrypt/bson-3"]
3437
sync = []
3538
rustls-tls = ["dep:rustls", "dep:tokio-rustls"]
3639
openssl-tls = ["dep:openssl", "dep:openssl-probe", "dep:tokio-openssl"]
@@ -73,7 +76,6 @@ tracing-unstable = ["dep:tracing", "dep:log"]
7376
async-trait = "0.1.42"
7477
base64 = "0.13.0"
7578
bitflags = "1.1.0"
76-
bson = { git = "https://github.com/mongodb/bson-rust", branch = "main", version = "2.14.0" }
7779
chrono = { version = "0.4.7", default-features = false, features = [
7880
"clock",
7981
"std",
@@ -92,7 +94,6 @@ hmac = "0.12.1"
9294
once_cell = "1.19.0"
9395
log = { version = "0.4.17", optional = true }
9496
md-5 = "0.10.1"
95-
mongocrypt = { git = "https://github.com/mongodb/libmongocrypt-rust.git", branch = "main", optional = true, version = "0.2.1" }
9697
mongodb-internal-macros = { path = "macros", version = "3.2.3" }
9798
num_cpus = { version = "1.13.1", optional = true }
9899
openssl = { version = "0.10.38", optional = true }
@@ -120,6 +121,27 @@ zstd = { version = "0.11.2", optional = true }
120121
macro_magic = "0.5.1"
121122
rustversion = "1.0.20"
122123

124+
[dependencies.bson2]
125+
git = "https://github.com/mongodb/bson-rust"
126+
branch = "2.15.x"
127+
package = "bson"
128+
version = "2.15.0"
129+
optional = true
130+
131+
[dependencies.bson3]
132+
git = "https://github.com/mongodb/bson-rust"
133+
branch = "main"
134+
package = "bson"
135+
version = "3.0.0"
136+
optional = true
137+
138+
[dependencies.mongocrypt]
139+
git = "https://github.com/mongodb/libmongocrypt-rust.git"
140+
branch = "main"
141+
version = "0.3.0"
142+
default-features = false
143+
optional = true
144+
123145
[dependencies.pbkdf2]
124146
version = "0.11.0"
125147
default-features = false

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ For more details, including features, runnable examples, troubleshooting resourc
77

88
## Installation
99
### Requirements
10-
- Rust 1.74.0+ (See the [MSRV policy](#minimum-supported-rust-version-msrv-policy) for more information)
10+
- Rust 1.81.0+ (See the [MSRV policy](#minimum-supported-rust-version-msrv-policy) for more information)
1111
- MongoDB 4.0+
1212

1313
#### Supported Platforms
@@ -149,7 +149,7 @@ Commits to main are run automatically on [evergreen](https://evergreen.mongodb.c
149149

150150
## Minimum supported Rust version (MSRV) policy
151151

152-
The MSRV for this crate is currently 1.74.0. Increases to the MSRV will only happen in a minor or major version release, and will be to a Rust version at least six months old.
152+
The MSRV for this crate is currently 1.81.0. Increases to the MSRV will only happen in a minor or major version release, and will be to a Rust version at least six months old.
153153

154154
## License
155155

clippy.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
msrv = "1.74.0"
1+
msrv = "1.81.0"

src/action.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,7 @@ pub trait Action: private::Sealed + IntoFuture {
8888
/// If the value is `Some`, call the provided function on `self`. Convenient for chained
8989
/// updates with values that need to be set conditionally. For example:
9090
/// ```rust
91-
/// # use mongodb::{Client, error::Result};
92-
/// # use bson::Document;
91+
/// # use mongodb::{Client, error::Result, bson::Document};
9392
/// use mongodb::action::Action;
9493
/// async fn list_my_collections(client: &Client, filter: Option<Document>) -> Result<Vec<String>> {
9594
/// client.database("my_db")

src/action/aggregate.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::{marker::PhantomData, time::Duration};
22

3-
use bson::{Bson, Document};
3+
use crate::bson::{Bson, Document};
44

55
use crate::{
66
coll::options::{AggregateOptions, Hint},

src/action/count.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use bson::{Bson, Document};
1+
use crate::bson::{Bson, Document};
22
use std::time::Duration;
33

44
use crate::{

0 commit comments

Comments
 (0)