Skip to content

Commit 20da9b1

Browse files
authored
RUST-2169 Clean up and future-proof features (#544)
1 parent 9995832 commit 20da9b1

File tree

12 files changed

+66
-216
lines changed

12 files changed

+66
-216
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,24 +33,18 @@ exclude = [
3333
]
3434

3535
[features]
36-
default = []
36+
default = ["compat-3-0-0"]
37+
compat-3-0-0 = []
3738
# if enabled, include API for interfacing with chrono 0.4
38-
chrono-0_4 = ["chrono"]
39+
chrono-0_4 = ["dep:chrono"]
3940
# if enabled, include API for interfacing with uuid 1.x
4041
uuid-1 = []
4142
# if enabled, include API for interfacing with time 0.3
4243
time-0_3 = []
43-
# If enabled, implement Hash/Eq for Bson and Document
44-
hashable = []
45-
# If enabled, the maximum document size will be increased from the MongoDB cap
46-
# of 16 MB to the BSON spec maximum size of 2^31 - 1
47-
uncapped_max_size = []
4844
serde_path_to_error = ["dep:serde_path_to_error"]
4945
# if enabled, include serde_with interop.
5046
# should be used in conjunction with chrono-0_4 or uuid-0_8.
51-
# it's commented out here because Cargo implicitly adds a feature flag for
52-
# all optional dependencies.
53-
# serde_with
47+
serde_with-3 = ["dep:serde_with"]
5448

5549
[lib]
5650
name = "bson"
@@ -67,8 +61,7 @@ base64 = "0.22.1"
6761
once_cell = "1.5.1"
6862
uuid = { version = "1.1.2", features = ["serde", "v4"] }
6963
serde_bytes = "0.11.5"
70-
serde_with = { version = "1.3.1", optional = true }
71-
serde_with-3 = { package = "serde_with", version = "3.1.0", optional = true }
64+
serde_with = { version = "3.1.0", optional = true }
7265
time = { version = "0.3.9", features = ["formatting", "parsing", "macros", "large-dates"] }
7366
bitvec = "1.0.1"
7467
serde_path_to_error = { version = "0.1.16", optional = true }

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,9 @@ Note that if you are using `bson` through the `mongodb` crate, you do not need t
5050
| `chrono-0_4` | Enable support for v0.4 of the [`chrono`](https://docs.rs/chrono/0.4) crate in the public API. | n/a | no |
5151
| `uuid-1` | Enable support for v1.x of the [`uuid`](https://docs.rs/uuid/1.0) crate in the public API. | n/a | no |
5252
| `time-0_3` | Enable support for v0.3 of the [`time`](https://docs.rs/time/0.3) crate in the public API. | n/a | no |
53-
| `serde_with` | Enable [`serde_with`](https://docs.rs/serde_with/1.x) 1.x integrations for `bson::DateTime` and `bson::Uuid`.| serde_with | no |
5453
| `serde_with-3` | Enable [`serde_with`](https://docs.rs/serde_with/3.x) 3.x integrations for `bson::DateTime` and `bson::Uuid`.| serde_with | no |
5554
| `serde_path_to_error` | Enable support for error paths via integration with [`serde_path_to_error`](https://docs.rs/serde_path_to_err/latest). This is an unstable feature and any breaking changes to `serde_path_to_error` may affect usage of it via this feature. | serde_path_to_error | no |
56-
| `hashable` | Implement `core::hash::Hash` and `std::cmp::Eq` on `Bson` and `Document`. | n/a | no |
57-
| `uncapped_max_size` | Increase the maximum document size from the MongoDB cap of 16 MB to the BSON spec maximum size of 2^31 - 1 bytes. | n/a | no |
55+
| `compat-3-0-0` | Required for future compatibility if default features are disabled. | no |
5856

5957
## Overview of the BSON Format
6058

serde-tests/Cargo.lock

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

serde-tests/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@ edition = "2018"
88
default = []
99

1010
[dependencies]
11-
bson = { path = "..", features = ["uuid-1", "chrono-0_4", "serde_with"] }
11+
bson = { path = "..", features = ["uuid-1", "chrono-0_4", "serde_with-3"] }
1212
serde = { version = "1.0", features = ["derive"] }
1313
pretty_assertions = "0.6.1"
1414
hex = "0.4.2"
15-
serde_with = "1"
15+
serde_with = "3"
1616
chrono = "0.4"
1717
uuid = "1"
1818

src/bson.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ pub enum Bson {
9090
/// Alias for `Vec<Bson>`.
9191
pub type Array = Vec<Bson>;
9292

93-
#[cfg(feature = "hashable")]
9493
impl Hash for Bson {
9594
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
9695
match self {
@@ -125,7 +124,6 @@ impl Hash for Bson {
125124
}
126125
}
127126

128-
#[cfg(feature = "hashable")]
129127
impl Eq for Bson {}
130128

131129
impl Display for Bson {
@@ -1154,8 +1152,7 @@ impl Display for Regex {
11541152
}
11551153

11561154
/// Represents a BSON code with scope value.
1157-
#[derive(Debug, Clone, PartialEq)]
1158-
#[cfg_attr(feature = "hashable", derive(Eq, Hash))]
1155+
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
11591156
pub struct JavaScriptCodeWithScope {
11601157
/// The JavaScript code.
11611158
pub code: String,

0 commit comments

Comments
 (0)