@@ -1100,18 +1100,29 @@ impl ClientOptions {
1100
1100
uri : impl AsRef < str > ,
1101
1101
resolver_config : Option < ResolverConfig > ,
1102
1102
) -> Result < Self > {
1103
- Self :: parse_connection_string ( ConnectionString :: parse ( uri) ?, resolver_config) . await
1103
+ Self :: parse_connection_string_internal ( ConnectionString :: parse ( uri) ?, resolver_config) . await
1104
1104
}
1105
1105
1106
1106
/// Creates a `ClientOptions` from the given `ConnectionString`.
1107
1107
///
1108
1108
/// In the case that "mongodb+srv" is used, SRV and TXT record lookups will be done using the
1109
1109
/// provided `ResolverConfig` as part of this method.
1110
- pub async fn parse_connection_string (
1110
+ pub async fn parse_connection_string_with_resolver_config (
1111
+ conn_str : ConnectionString ,
1112
+ resolver_config : ResolverConfig ,
1113
+ ) -> Result < Self > {
1114
+ Self :: parse_connection_string_internal ( conn_str, Some ( resolver_config) ) . await
1115
+ }
1116
+
1117
+ /// Creates a `ClientOptions` from the given `ConnectionString`.
1118
+ pub async fn parse_connection_string ( conn_str : ConnectionString ) -> Result < Self > {
1119
+ Self :: parse_connection_string_internal ( conn_str, None ) . await
1120
+ }
1121
+
1122
+ async fn parse_connection_string_internal (
1111
1123
mut conn_str : ConnectionString ,
1112
- resolver_config : impl Into < Option < ResolverConfig > > ,
1124
+ resolver_config : Option < ResolverConfig > ,
1113
1125
) -> Result < Self > {
1114
- let resolver_config = resolver_config. into ( ) ;
1115
1126
let auth_source_present = conn_str
1116
1127
. credential
1117
1128
. as_ref ( )
@@ -1172,16 +1183,25 @@ impl ClientOptions {
1172
1183
Ok ( options)
1173
1184
}
1174
1185
1186
+ /// Creates a `ClientOptions` from the given `ConnectionString`.
1187
+ #[ cfg( any( feature = "sync" , feature = "tokio-sync" ) ) ]
1188
+ pub fn parse_connection_string_sync ( conn_str : ConnectionString ) -> Result < Self > {
1189
+ crate :: runtime:: block_on ( Self :: parse_connection_string_internal ( conn_str, None ) )
1190
+ }
1191
+
1175
1192
/// Creates a `ClientOptions` from the given `ConnectionString`.
1176
1193
///
1177
1194
/// In the case that "mongodb+srv" is used, SRV and TXT record lookups will be done using the
1178
1195
/// provided `ResolverConfig` as part of this method.
1179
1196
#[ cfg( any( feature = "sync" , feature = "tokio-sync" ) ) ]
1180
- pub fn parse_connection_string_sync (
1197
+ pub fn parse_connection_string_with_resolver_config_sync (
1181
1198
conn_str : ConnectionString ,
1182
- resolver_config : impl Into < Option < ResolverConfig > > ,
1199
+ resolver_config : ResolverConfig ,
1183
1200
) -> Result < Self > {
1184
- crate :: runtime:: block_on ( Self :: parse_connection_string ( conn_str, resolver_config) )
1201
+ crate :: runtime:: block_on ( Self :: parse_connection_string_internal (
1202
+ conn_str,
1203
+ Some ( resolver_config) ,
1204
+ ) )
1185
1205
}
1186
1206
1187
1207
fn from_connection_string ( conn_str : ConnectionString ) -> Self {
0 commit comments