Skip to content

Commit dff0e55

Browse files
RUST-1380 Drop support for uuid 0.8 (#534)
1 parent fc10678 commit dff0e55

File tree

10 files changed

+5
-298
lines changed

10 files changed

+5
-298
lines changed

Cargo.lock

Lines changed: 1 addition & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,6 @@ exclude = [
3636
default = []
3737
# if enabled, include API for interfacing with chrono 0.4
3838
chrono-0_4 = ["chrono"]
39-
# if enabled, include API for interfacing with uuid 0.8
40-
# This is commented out because Cargo implicitly adds this feature since
41-
# uuid-0_8 is also an optional dependency.
42-
# uuid-0_8 = []
4339
# if enabled, include API for interfacing with uuid 1.x
4440
uuid-1 = []
4541
# if enabled, include API for interfacing with time 0.3
@@ -69,7 +65,6 @@ indexmap = "2.1.0"
6965
hex = "0.4.2"
7066
base64 = "0.22.1"
7167
once_cell = "1.5.1"
72-
uuid-0_8 = { package = "uuid", version = "0.8.1", features = ["serde", "v4"], optional = true }
7368
uuid = { version = "1.1.2", features = ["serde", "v4"] }
7469
serde_bytes = "0.11.5"
7570
serde_with = { version = "1.3.1", optional = true }

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ Note that if you are using `bson` through the `mongodb` crate, you do not need t
4848
| Feature | Description | Extra dependencies | Default |
4949
| :----------- | :---------------------------------------------------------------------------------------------------------- | :----------------- | :------ |
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 |
51-
| `uuid-0_8` | Enable support for v0.8 of the [`uuid`](https://docs.rs/uuid/0.8) crate in the public API. | n/a | no |
5251
| `uuid-1` | Enable support for v1.x of the [`uuid`](https://docs.rs/uuid/1.0) crate in the public API. | n/a | no |
5352
| `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 |
5453
| `serde_with` | Enable [`serde_with`](https://docs.rs/serde_with/1.x) 1.x integrations for `bson::DateTime` and `bson::Uuid`.| serde_with | no |

serde-tests/Cargo.lock

Lines changed: 2 additions & 13 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,13 +8,13 @@ edition = "2018"
88
default = []
99

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

1919
[dev-dependencies]
2020
serde_json = "1"

src/bson.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -414,14 +414,6 @@ impl<T: chrono::TimeZone> From<chrono::DateTime<T>> for Bson {
414414
}
415415
}
416416

417-
#[cfg(feature = "uuid-0_8")]
418-
#[cfg_attr(docsrs, doc(cfg(feature = "uuid-0_8")))]
419-
impl From<uuid_0_8::Uuid> for Bson {
420-
fn from(uuid: uuid_0_8::Uuid) -> Self {
421-
Bson::Binary(uuid.into())
422-
}
423-
}
424-
425417
#[cfg(feature = "uuid-1")]
426418
#[cfg_attr(docsrs, doc(cfg(feature = "uuid-1")))]
427419
impl From<uuid::Uuid> for Bson {

src/serde_helpers.rs

Lines changed: 0 additions & 131 deletions
Original file line numberDiff line numberDiff line change
@@ -83,30 +83,6 @@ pub use uuid_1_as_python_legacy_binary::{
8383
deserialize as deserialize_uuid_1_from_python_legacy_binary,
8484
serialize as serialize_uuid_1_as_python_legacy_binary,
8585
};
86-
#[cfg(feature = "uuid-0_8")]
87-
#[doc(inline)]
88-
pub use uuid_as_binary::{
89-
deserialize as deserialize_uuid_from_binary,
90-
serialize as serialize_uuid_as_binary,
91-
};
92-
#[cfg(feature = "uuid-0_8")]
93-
#[doc(inline)]
94-
pub use uuid_as_c_sharp_legacy_binary::{
95-
deserialize as deserialize_uuid_from_c_sharp_legacy_binary,
96-
serialize as serialize_uuid_as_c_sharp_legacy_binary,
97-
};
98-
#[cfg(feature = "uuid-0_8")]
99-
#[doc(inline)]
100-
pub use uuid_as_java_legacy_binary::{
101-
deserialize as deserialize_uuid_from_java_legacy_binary,
102-
serialize as serialize_uuid_as_java_legacy_binary,
103-
};
104-
#[cfg(feature = "uuid-0_8")]
105-
#[doc(inline)]
106-
pub use uuid_as_python_legacy_binary::{
107-
deserialize as deserialize_uuid_from_python_legacy_binary,
108-
serialize as serialize_uuid_as_python_legacy_binary,
109-
};
11086

11187
/// Attempts to serialize a u32 as an i32. Errors if an exact conversion is not possible.
11288
pub fn serialize_u32_as_i32<S: Serializer>(val: &u32, serializer: S) -> Result<S::Ok, S::Error> {
@@ -527,29 +503,6 @@ macro_rules! as_binary_mod {
527503
};
528504
}
529505

530-
/// Contains functions to serialize a [`uuid_0_8::Uuid`] as a [`crate::Binary`] and deserialize a
531-
/// [`uuid_0_8::Uuid`] from a [`crate::Binary`].
532-
///
533-
/// ```rust
534-
/// # #[cfg(feature = "uuid-0_8")]
535-
/// # {
536-
/// use serde::{Serialize, Deserialize};
537-
/// use uuid_0_8::Uuid;
538-
/// use bson::serde_helpers::uuid_as_binary;
539-
///
540-
/// #[derive(Serialize, Deserialize)]
541-
/// struct Item {
542-
/// #[serde(with = "uuid_as_binary")]
543-
/// pub id: Uuid,
544-
/// }
545-
/// # }
546-
/// ```
547-
#[cfg(feature = "uuid-0_8")]
548-
#[cfg_attr(docsrs, doc(cfg(feature = "uuid-0_8")))]
549-
pub mod uuid_as_binary {
550-
as_binary_mod!(cfg(feature = "uuid-0_8"), uuid_0_8::Uuid);
551-
}
552-
553506
/// Contains functions to serialize a [`uuid::Uuid`] as a [`crate::Binary`] and deserialize a
554507
/// [`uuid::Uuid`] from a [`crate::Binary`].
555508
///
@@ -603,34 +556,6 @@ macro_rules! as_legacy_binary_mod {
603556
};
604557
}
605558

606-
/// Contains functions to serialize a [`uuid_0_8::Uuid`] to a [`crate::Binary`] in the legacy
607-
/// Java driver UUID format and deserialize [`uuid_0_8::Uuid`] from a [`crate::Binary`] in the
608-
/// legacy Java driver format.
609-
///
610-
/// ```rust
611-
/// #[cfg(feature = "uuid-0_8")]
612-
/// # {
613-
/// use serde::{Serialize, Deserialize};
614-
/// use uuid_0_8::Uuid;
615-
/// use bson::serde_helpers::uuid_as_java_legacy_binary;
616-
///
617-
/// #[derive(Serialize, Deserialize)]
618-
/// struct Item {
619-
/// #[serde(with = "uuid_as_java_legacy_binary")]
620-
/// pub id: Uuid,
621-
/// }
622-
/// # }
623-
/// ```
624-
#[cfg(feature = "uuid-0_8")]
625-
#[cfg_attr(docsrs, doc(cfg(feature = "uuid-0_8")))]
626-
pub mod uuid_as_java_legacy_binary {
627-
as_legacy_binary_mod!(
628-
cfg(feature = "uuid-0_8"),
629-
uuid_0_8::Uuid,
630-
UuidRepresentation::JavaLegacy
631-
);
632-
}
633-
634559
/// Contains functions to serialize a [`uuid::Uuid`] to a [`crate::Binary`] in the legacy
635560
/// Java driver UUID format and deserialize [`uuid::Uuid`] from a [`crate::Binary`] in the legacy
636561
/// Java driver format.
@@ -659,34 +584,6 @@ pub mod uuid_1_as_java_legacy_binary {
659584
);
660585
}
661586

662-
/// Contains functions to serialize a [`uuid_0_8::Uuid`] to a [`crate::Binary`] in the legacy Python
663-
/// driver UUID format and deserialize [`uuid_0_8::Uuid`] from a [`crate::Binary`] in the legacy
664-
/// Python driver format.
665-
///
666-
/// ```rust
667-
/// # #[cfg(feature = "uuid-0_8")]
668-
/// # {
669-
/// use serde::{Serialize, Deserialize};
670-
/// use uuid_0_8::Uuid;
671-
/// use bson::serde_helpers::uuid_as_python_legacy_binary;
672-
///
673-
/// #[derive(Serialize, Deserialize)]
674-
/// struct Item {
675-
/// #[serde(with = "uuid_as_python_legacy_binary")]
676-
/// pub id: Uuid,
677-
/// }
678-
/// # }
679-
/// ```
680-
#[cfg(feature = "uuid-0_8")]
681-
#[cfg_attr(docsrs, doc(cfg(feature = "uuid-0_8")))]
682-
pub mod uuid_as_python_legacy_binary {
683-
as_legacy_binary_mod!(
684-
cfg(feature = "uuid-0_8"),
685-
uuid_0_8::Uuid,
686-
UuidRepresentation::PythonLegacy
687-
);
688-
}
689-
690587
/// Contains functions to serialize a [`uuid::Uuid`] to a [`crate::Binary`] in the legacy Python
691588
/// driver UUID format and deserialize [`uuid::Uuid`] from a [`crate::Binary`] in the legacy Python
692589
/// driver format.
@@ -715,34 +612,6 @@ pub mod uuid_1_as_python_legacy_binary {
715612
);
716613
}
717614

718-
/// Contains functions to serialize a [`uuid_0_8::Uuid`] to a [`crate::Binary`] in the legacy C#
719-
/// driver UUID format and deserialize [`uuid_0_8::Uuid`] from a [`crate::Binary`] in the legacy C#
720-
/// driver format.
721-
///
722-
/// ```rust
723-
/// # #[cfg(feature = "uuid-0_8")]
724-
/// # {
725-
/// use serde::{Serialize, Deserialize};
726-
/// use uuid_0_8::Uuid;
727-
/// use bson::serde_helpers::uuid_as_c_sharp_legacy_binary;
728-
///
729-
/// #[derive(Serialize, Deserialize)]
730-
/// struct Item {
731-
/// #[serde(with = "uuid_as_c_sharp_legacy_binary")]
732-
/// pub id: Uuid,
733-
/// }
734-
/// # }
735-
/// ```
736-
#[cfg(feature = "uuid-0_8")]
737-
#[cfg_attr(docsrs, doc(cfg(feature = "uuid-0_8")))]
738-
pub mod uuid_as_c_sharp_legacy_binary {
739-
as_legacy_binary_mod!(
740-
cfg(feature = "uuid-0_8"),
741-
uuid_0_8::Uuid,
742-
UuidRepresentation::CSharpLegacy
743-
);
744-
}
745-
746615
/// Contains functions to serialize a [`uuid::Uuid`] to a [`crate::Binary`] in the legacy C# driver
747616
/// UUID format and deserialize [`uuid::Uuid`] from a [`crate::Binary`] in the legacy C# driver
748617
/// format.

src/tests/serde.rs

Lines changed: 0 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -554,54 +554,6 @@ fn test_de_db_pointer() {
554554
assert_eq!(foo.db_pointer, db_pointer.clone());
555555
}
556556

557-
#[cfg(feature = "uuid-0_8")]
558-
#[test]
559-
fn test_serde_legacy_uuid_0_8() {
560-
use uuid_0_8::Uuid;
561-
562-
let _guard = LOCK.run_concurrently();
563-
564-
#[derive(Serialize, Deserialize)]
565-
struct Foo {
566-
#[serde(with = "serde_helpers::uuid_as_java_legacy_binary")]
567-
java_legacy: Uuid,
568-
#[serde(with = "serde_helpers::uuid_as_python_legacy_binary")]
569-
python_legacy: Uuid,
570-
#[serde(with = "serde_helpers::uuid_as_c_sharp_legacy_binary")]
571-
csharp_legacy: Uuid,
572-
}
573-
let uuid = Uuid::parse_str("00112233445566778899AABBCCDDEEFF").unwrap();
574-
let foo = Foo {
575-
java_legacy: uuid,
576-
python_legacy: uuid,
577-
csharp_legacy: uuid,
578-
};
579-
580-
let x = to_bson(&foo).unwrap();
581-
assert_eq!(
582-
x.as_document().unwrap(),
583-
&doc! {
584-
"java_legacy": Bson::Binary(Binary{
585-
subtype:BinarySubtype::UuidOld,
586-
bytes: hex::decode("7766554433221100FFEEDDCCBBAA9988").unwrap(),
587-
}),
588-
"python_legacy": Bson::Binary(Binary{
589-
subtype:BinarySubtype::UuidOld,
590-
bytes: hex::decode("00112233445566778899AABBCCDDEEFF").unwrap(),
591-
}),
592-
"csharp_legacy": Bson::Binary(Binary{
593-
subtype:BinarySubtype::UuidOld,
594-
bytes: hex::decode("33221100554477668899AABBCCDDEEFF").unwrap(),
595-
})
596-
}
597-
);
598-
599-
let foo: Foo = from_bson(x).unwrap();
600-
assert_eq!(foo.java_legacy, uuid);
601-
assert_eq!(foo.python_legacy, uuid);
602-
assert_eq!(foo.csharp_legacy, uuid);
603-
}
604-
605557
#[cfg(feature = "uuid-1")]
606558
#[test]
607559
fn test_serde_legacy_uuid_1() {
@@ -988,34 +940,6 @@ fn test_i64_as_bson_datetime() {
988940
assert_eq!(a.now, now.timestamp_millis());
989941
}
990942

991-
#[test]
992-
#[cfg(feature = "uuid-0_8")]
993-
fn test_uuid_0_8_helpers() {
994-
use serde_helpers::uuid_as_binary;
995-
use uuid_0_8::Uuid;
996-
997-
let _guard = LOCK.run_concurrently();
998-
999-
#[derive(Serialize, Deserialize)]
1000-
struct A {
1001-
#[serde(with = "uuid_as_binary")]
1002-
uuid: Uuid,
1003-
}
1004-
1005-
let uuid = Uuid::parse_str("936DA01F9ABD4d9d80C702AF85C822A8").unwrap();
1006-
let a = A { uuid };
1007-
let doc = to_document(&a).unwrap();
1008-
match doc.get("uuid").unwrap() {
1009-
Bson::Binary(bin) => {
1010-
assert_eq!(bin.subtype, BinarySubtype::Uuid);
1011-
assert_eq!(bin.bytes, uuid.as_bytes());
1012-
}
1013-
_ => panic!("expected Bson::Binary"),
1014-
}
1015-
let a: A = from_document(doc).unwrap();
1016-
assert_eq!(a.uuid, uuid);
1017-
}
1018-
1019943
#[test]
1020944
#[cfg(feature = "uuid-1")]
1021945
fn test_uuid_1_helpers() {

0 commit comments

Comments
 (0)