@@ -6,13 +6,7 @@ use typed_builder::TypedBuilder;
66
77use crate :: {
88 bson:: { doc, Bson , Document } ,
9- bson_util:: {
10- deserialize_duration_from_u64_millis,
11- serialize_batch_size,
12- serialize_duration_as_int_millis,
13- serialize_u32_option_as_i32,
14- serialize_u64_option_as_i64,
15- } ,
9+ bson_util,
1610 concern:: { ReadConcern , WriteConcern } ,
1711 options:: Collation ,
1812 selection_criteria:: SelectionCriteria ,
@@ -427,7 +421,10 @@ pub struct AggregateOptions {
427421 /// only the number of documents kept in memory at a given time (and by extension, the
428422 /// number of round trips needed to return the entire set of documents returned by the
429423 /// query).
430- #[ serde( serialize_with = "serialize_batch_size" , rename( serialize = "cursor" ) ) ]
424+ #[ serde(
425+ serialize_with = "bson_util::serialize_u32_option_as_batch_size" ,
426+ rename( serialize = "cursor" )
427+ ) ]
431428 pub batch_size : Option < u32 > ,
432429
433430 /// Opt out of document-level validation.
@@ -452,7 +449,7 @@ pub struct AggregateOptions {
452449 /// This option will have no effect on non-tailable cursors that result from this operation.
453450 #[ serde(
454451 skip_serializing,
455- deserialize_with = "deserialize_duration_from_u64_millis " ,
452+ deserialize_with = "bson_util::deserialize_duration_option_from_u64_millis " ,
456453 default
457454 ) ]
458455 pub max_await_time : Option < Duration > ,
@@ -462,9 +459,9 @@ pub struct AggregateOptions {
462459 /// This options maps to the `maxTimeMS` MongoDB query option, so the duration will be sent
463460 /// across the wire as an integer number of milliseconds.
464461 #[ serde(
465- serialize_with = "serialize_duration_as_int_millis " ,
462+ serialize_with = "bson_util::serialize_duration_option_as_int_millis " ,
466463 rename = "maxTimeMS" ,
467- deserialize_with = "deserialize_duration_from_u64_millis " ,
464+ deserialize_with = "bson_util::deserialize_duration_option_from_u64_millis " ,
468465 default
469466 ) ]
470467 pub max_time : Option < Duration > ,
@@ -518,7 +515,10 @@ pub struct CountOptions {
518515 ///
519516 /// This options maps to the `maxTimeMS` MongoDB query option, so the duration will be sent
520517 /// across the wire as an integer number of milliseconds.
521- #[ serde( default , deserialize_with = "deserialize_duration_from_u64_millis" ) ]
518+ #[ serde(
519+ default ,
520+ deserialize_with = "bson_util::deserialize_duration_option_from_u64_millis"
521+ ) ]
522522 pub max_time : Option < Duration > ,
523523
524524 /// The number of documents to skip before counting.
@@ -558,9 +558,9 @@ pub struct EstimatedDocumentCountOptions {
558558 /// across the wire as an integer number of milliseconds.
559559 #[ serde(
560560 default ,
561- serialize_with = "serialize_duration_as_int_millis " ,
561+ serialize_with = "bson_util::serialize_duration_option_as_int_millis " ,
562562 rename = "maxTimeMS" ,
563- deserialize_with = "deserialize_duration_from_u64_millis "
563+ deserialize_with = "bson_util::deserialize_duration_option_from_u64_millis "
564564 ) ]
565565 pub max_time : Option < Duration > ,
566566
@@ -588,9 +588,9 @@ pub struct DistinctOptions {
588588 /// across the wire as an integer number of milliseconds.
589589 #[ serde(
590590 default ,
591- serialize_with = "serialize_duration_as_int_millis " ,
591+ serialize_with = "bson_util::serialize_duration_option_as_int_millis " ,
592592 rename = "maxTimeMS" ,
593- deserialize_with = "deserialize_duration_from_u64_millis "
593+ deserialize_with = "bson_util::deserialize_duration_option_from_u64_millis "
594594 ) ]
595595 pub max_time : Option < Duration > ,
596596
@@ -633,7 +633,7 @@ pub struct FindOptions {
633633 /// only the number of documents kept in memory at a given time (and by extension, the
634634 /// number of round trips needed to return the entire set of documents returned by the
635635 /// query.
636- #[ serde( serialize_with = "serialize_u32_option_as_i32" ) ]
636+ #[ serde( serialize_with = "bson_util:: serialize_u32_option_as_i32" ) ]
637637 pub batch_size : Option < u32 > ,
638638
639639 /// Tags the query with an arbitrary string to help trace the operation through the database
@@ -665,7 +665,7 @@ pub struct FindOptions {
665665 ///
666666 /// Note: this option is deprecated starting in MongoDB version 4.0 and removed in MongoDB 4.2.
667667 /// Use the maxTimeMS option instead.
668- #[ serde( serialize_with = "serialize_u64_option_as_i64" ) ]
668+ #[ serde( serialize_with = "bson_util:: serialize_u64_option_as_i64" ) ]
669669 pub max_scan : Option < u64 > ,
670670
671671 /// The maximum amount of time to allow the query to run.
@@ -674,7 +674,7 @@ pub struct FindOptions {
674674 /// across the wire as an integer number of milliseconds.
675675 #[ serde(
676676 rename = "maxTimeMS" ,
677- serialize_with = "serialize_duration_as_int_millis "
677+ serialize_with = "bson_util::serialize_duration_option_as_int_millis "
678678 ) ]
679679 pub max_time : Option < Duration > ,
680680
@@ -705,7 +705,7 @@ pub struct FindOptions {
705705 pub show_record_id : Option < bool > ,
706706
707707 /// The number of documents to skip before counting.
708- #[ serde( serialize_with = "serialize_u64_option_as_i64" ) ]
708+ #[ serde( serialize_with = "bson_util:: serialize_u64_option_as_i64" ) ]
709709 pub skip : Option < u64 > ,
710710
711711 /// The order of the documents for the purposes of the operation.
@@ -791,14 +791,14 @@ pub struct FindOneOptions {
791791 ///
792792 /// Note: this option is deprecated starting in MongoDB version 4.0 and removed in MongoDB 4.2.
793793 /// Use the maxTimeMS option instead.
794- #[ serde( serialize_with = "serialize_u64_option_as_i64" ) ]
794+ #[ serde( serialize_with = "bson_util:: serialize_u64_option_as_i64" ) ]
795795 pub max_scan : Option < u64 > ,
796796
797797 /// The maximum amount of time to allow the query to run.
798798 ///
799799 /// This options maps to the `maxTimeMS` MongoDB query option, so the duration will be sent
800800 /// across the wire as an integer number of milliseconds.
801- #[ serde( deserialize_with = "deserialize_duration_from_u64_millis " ) ]
801+ #[ serde( deserialize_with = "bson_util::deserialize_duration_option_from_u64_millis " ) ]
802802 pub max_time : Option < Duration > ,
803803
804804 /// The inclusive lower bound for a specific index.
@@ -824,7 +824,7 @@ pub struct FindOneOptions {
824824 pub show_record_id : Option < bool > ,
825825
826826 /// The number of documents to skip before counting.
827- #[ serde( serialize_with = "serialize_u64_option_as_i64" ) ]
827+ #[ serde( serialize_with = "bson_util:: serialize_u64_option_as_i64" ) ]
828828 pub skip : Option < u64 > ,
829829
830830 /// The order of the documents for the purposes of the operation.
0 commit comments