@@ -13,27 +13,41 @@ use crate::{
1313 serde_util,
1414} ;
1515
16- /// These are the valid options for creating a [`Collection`](../struct.Collection.html) with
17- /// [`Database::collection_with_options`](../struct.Database.html#method.collection_with_options).
18- #[ derive( Clone , Debug , Default , Deserialize , TypedBuilder ) ]
19- #[ builder( field_defaults( default , setter( into) ) ) ]
20- #[ serde( rename_all = "camelCase" ) ]
21- #[ non_exhaustive]
22- pub struct CollectionOptions {
23- /// The default read preference for operations.
24- pub selection_criteria : Option < SelectionCriteria > ,
25-
26- /// The default read concern for operations.
27- pub read_concern : Option < ReadConcern > ,
28-
29- /// The default write concern for operations.
30- pub write_concern : Option < WriteConcern > ,
31-
32- /// Sets the [`bson::SerializerOptions::human_readable`] option for the [`Bson`] serializer.
33- /// The default value is `false`.
34- /// Note: Specifying `true` for this value will decrease the performance of insert operations.
35- pub human_readable_serialization : Option < bool > ,
16+ // Generated code for `Deserialize` or `TypedBuilder` causes a deprecation warning; annotating the
17+ // field or struct doesn't fix it because that annotation isn't propagated by the code generator.
18+ // This works around that by defining it in a non-pub module and immediately re-exporting that
19+ // module's contents.
20+ #[ allow( deprecated) ]
21+ mod suppress_warning {
22+ use super :: * ;
23+
24+ /// These are the valid options for creating a [`Collection`](../struct.Collection.html) with
25+ /// [`Database::collection_with_options`](../struct.Database.html#method.
26+ /// collection_with_options).
27+ #[ derive( Clone , Debug , Default , Deserialize , TypedBuilder ) ]
28+ #[ builder( field_defaults( default , setter( into) ) ) ]
29+ #[ serde( rename_all = "camelCase" ) ]
30+ #[ non_exhaustive]
31+ pub struct CollectionOptions {
32+ /// The default read preference for operations.
33+ pub selection_criteria : Option < SelectionCriteria > ,
34+
35+ /// The default read concern for operations.
36+ pub read_concern : Option < ReadConcern > ,
37+
38+ /// The default write concern for operations.
39+ pub write_concern : Option < WriteConcern > ,
40+
41+ /// Sets the [`bson::SerializerOptions::human_readable`] option for the [`Bson`]
42+ /// serializer. The default value is `false`.
43+ /// Note: Specifying `true` for this value will decrease the performance of insert
44+ /// operations.
45+ #[ deprecated = "This is a workaround for a potential bug related to RUST-1687, and should \
46+ not be used in new code."]
47+ pub human_readable_serialization : Option < bool > ,
48+ }
3649}
50+ pub use suppress_warning:: * ;
3751
3852/// Specifies whether a
3953/// [`Collection::find_one_and_replace`](../struct.Collection.html#method.find_one_and_replace) and
0 commit comments