@@ -15,6 +15,7 @@ use std::{
15
15
time:: Duration ,
16
16
} ;
17
17
18
+ use bson:: UuidRepresentation ;
18
19
use derivative:: Derivative ;
19
20
use lazy_static:: lazy_static;
20
21
use serde:: { de:: Unexpected , Deserialize , Deserializer , Serialize } ;
@@ -74,6 +75,7 @@ const URI_OPTIONS: &[&str] = &[
74
75
"tlsallowinvalidcertificates" ,
75
76
"tlscafile" ,
76
77
"tlscertificatekeyfile" ,
78
+ "uuidRepresentation" ,
77
79
"w" ,
78
80
"waitqueuetimeoutms" ,
79
81
"wtimeoutms" ,
@@ -813,6 +815,12 @@ pub struct ConnectionString {
813
815
/// Default read preference for the client.
814
816
pub read_preference : Option < ReadPreference > ,
815
817
818
+ /// The [`UuidRepresentation`] to use when decoding [`Binary`](bson::Binary) values with the
819
+ /// [`UuidOld`](bson::spec::BinarySubtype::UuidOld) subtype. This is not used by the
820
+ /// driver; client code can use this when deserializing relevant values with
821
+ /// [`Binary::to_uuid_with_representation`](bson::binary::Binary::to_uuid_with_representation).
822
+ pub uuid_representation : Option < UuidRepresentation > ,
823
+
816
824
wait_queue_timeout : Option < Duration > ,
817
825
tls_insecure : Option < bool > ,
818
826
@@ -2115,6 +2123,22 @@ impl ConnectionString {
2115
2123
) )
2116
2124
}
2117
2125
} ,
2126
+ "uuidrepresentation" => match value. to_lowercase ( ) . as_str ( ) {
2127
+ "csharplegacy" => self . uuid_representation = Some ( UuidRepresentation :: CSharpLegacy ) ,
2128
+ "javalegacy" => self . uuid_representation = Some ( UuidRepresentation :: JavaLegacy ) ,
2129
+ "pythonlegacy" => self . uuid_representation = Some ( UuidRepresentation :: PythonLegacy ) ,
2130
+ _ => {
2131
+ return Err ( ErrorKind :: InvalidArgument {
2132
+ message : format ! (
2133
+ "connection string `uuidRepresentation` option can be one of \
2134
+ `csharpLegacy`, `javaLegacy`, or `pythonLegacy`. Received invalid \
2135
+ `{}`",
2136
+ value
2137
+ ) ,
2138
+ }
2139
+ . into ( ) )
2140
+ }
2141
+ } ,
2118
2142
"w" => {
2119
2143
let mut write_concern = self . write_concern . get_or_insert_with ( Default :: default) ;
2120
2144
0 commit comments