Skip to content

Commit 7275afe

Browse files
RUST-1563 Make ReadPreferenceOptions optional (#1059)
1 parent 2b83a87 commit 7275afe

File tree

8 files changed

+357
-377
lines changed

8 files changed

+357
-377
lines changed

src/client/options.rs

Lines changed: 14 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -252,25 +252,6 @@ impl ServerAddress {
252252
})
253253
}
254254

255-
#[cfg(test)]
256-
pub(crate) fn into_document(self) -> Document {
257-
match self {
258-
Self::Tcp { host, port } => {
259-
doc! {
260-
"host": host,
261-
"port": port.map(|i| Bson::Int32(i.into())).unwrap_or(Bson::Null)
262-
}
263-
}
264-
#[cfg(unix)]
265-
Self::Unix { path } => {
266-
doc! {
267-
"host": path.to_string_lossy().as_ref(),
268-
"port": Bson::Null,
269-
}
270-
}
271-
}
272-
}
273-
274255
pub(crate) fn host(&self) -> Cow<'_, str> {
275256
match self {
276257
Self::Tcp { host, .. } => Cow::Borrowed(host.as_str()),
@@ -2837,18 +2818,20 @@ mod tests {
28372818
],
28382819
selection_criteria: Some(
28392820
ReadPreference::SecondaryPreferred {
2840-
options: ReadPreferenceOptions::builder()
2841-
.tag_sets(vec![
2842-
tag_set! {
2843-
"dc" => "ny",
2844-
"rack" => "1"
2845-
},
2846-
tag_set! {
2847-
"dc" => "ny"
2848-
},
2849-
tag_set! {},
2850-
])
2851-
.build()
2821+
options: Some(
2822+
ReadPreferenceOptions::builder()
2823+
.tag_sets(vec![
2824+
tag_set! {
2825+
"dc" => "ny",
2826+
"rack" => "1"
2827+
},
2828+
tag_set! {
2829+
"dc" => "ny"
2830+
},
2831+
tag_set! {},
2832+
])
2833+
.build()
2834+
)
28522835
}
28532836
.into()
28542837
),

0 commit comments

Comments
 (0)