@@ -6,13 +6,7 @@ use typed_builder::TypedBuilder;
6
6
7
7
use crate :: {
8
8
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,
16
10
concern:: { ReadConcern , WriteConcern } ,
17
11
options:: Collation ,
18
12
selection_criteria:: SelectionCriteria ,
@@ -427,7 +421,10 @@ pub struct AggregateOptions {
427
421
/// only the number of documents kept in memory at a given time (and by extension, the
428
422
/// number of round trips needed to return the entire set of documents returned by the
429
423
/// 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
+ ) ]
431
428
pub batch_size : Option < u32 > ,
432
429
433
430
/// Opt out of document-level validation.
@@ -452,7 +449,7 @@ pub struct AggregateOptions {
452
449
/// This option will have no effect on non-tailable cursors that result from this operation.
453
450
#[ serde(
454
451
skip_serializing,
455
- deserialize_with = "deserialize_duration_from_u64_millis " ,
452
+ deserialize_with = "bson_util::deserialize_duration_option_from_u64_millis " ,
456
453
default
457
454
) ]
458
455
pub max_await_time : Option < Duration > ,
@@ -462,9 +459,9 @@ pub struct AggregateOptions {
462
459
/// This options maps to the `maxTimeMS` MongoDB query option, so the duration will be sent
463
460
/// across the wire as an integer number of milliseconds.
464
461
#[ serde(
465
- serialize_with = "serialize_duration_as_int_millis " ,
462
+ serialize_with = "bson_util::serialize_duration_option_as_int_millis " ,
466
463
rename = "maxTimeMS" ,
467
- deserialize_with = "deserialize_duration_from_u64_millis " ,
464
+ deserialize_with = "bson_util::deserialize_duration_option_from_u64_millis " ,
468
465
default
469
466
) ]
470
467
pub max_time : Option < Duration > ,
@@ -518,7 +515,10 @@ pub struct CountOptions {
518
515
///
519
516
/// This options maps to the `maxTimeMS` MongoDB query option, so the duration will be sent
520
517
/// 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
+ ) ]
522
522
pub max_time : Option < Duration > ,
523
523
524
524
/// The number of documents to skip before counting.
@@ -558,9 +558,9 @@ pub struct EstimatedDocumentCountOptions {
558
558
/// across the wire as an integer number of milliseconds.
559
559
#[ serde(
560
560
default ,
561
- serialize_with = "serialize_duration_as_int_millis " ,
561
+ serialize_with = "bson_util::serialize_duration_option_as_int_millis " ,
562
562
rename = "maxTimeMS" ,
563
- deserialize_with = "deserialize_duration_from_u64_millis "
563
+ deserialize_with = "bson_util::deserialize_duration_option_from_u64_millis "
564
564
) ]
565
565
pub max_time : Option < Duration > ,
566
566
@@ -588,9 +588,9 @@ pub struct DistinctOptions {
588
588
/// across the wire as an integer number of milliseconds.
589
589
#[ serde(
590
590
default ,
591
- serialize_with = "serialize_duration_as_int_millis " ,
591
+ serialize_with = "bson_util::serialize_duration_option_as_int_millis " ,
592
592
rename = "maxTimeMS" ,
593
- deserialize_with = "deserialize_duration_from_u64_millis "
593
+ deserialize_with = "bson_util::deserialize_duration_option_from_u64_millis "
594
594
) ]
595
595
pub max_time : Option < Duration > ,
596
596
@@ -633,7 +633,7 @@ pub struct FindOptions {
633
633
/// only the number of documents kept in memory at a given time (and by extension, the
634
634
/// number of round trips needed to return the entire set of documents returned by the
635
635
/// query.
636
- #[ serde( serialize_with = "serialize_u32_option_as_i32" ) ]
636
+ #[ serde( serialize_with = "bson_util:: serialize_u32_option_as_i32" ) ]
637
637
pub batch_size : Option < u32 > ,
638
638
639
639
/// Tags the query with an arbitrary string to help trace the operation through the database
@@ -665,7 +665,7 @@ pub struct FindOptions {
665
665
///
666
666
/// Note: this option is deprecated starting in MongoDB version 4.0 and removed in MongoDB 4.2.
667
667
/// 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" ) ]
669
669
pub max_scan : Option < u64 > ,
670
670
671
671
/// The maximum amount of time to allow the query to run.
@@ -674,7 +674,7 @@ pub struct FindOptions {
674
674
/// across the wire as an integer number of milliseconds.
675
675
#[ serde(
676
676
rename = "maxTimeMS" ,
677
- serialize_with = "serialize_duration_as_int_millis "
677
+ serialize_with = "bson_util::serialize_duration_option_as_int_millis "
678
678
) ]
679
679
pub max_time : Option < Duration > ,
680
680
@@ -705,7 +705,7 @@ pub struct FindOptions {
705
705
pub show_record_id : Option < bool > ,
706
706
707
707
/// 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" ) ]
709
709
pub skip : Option < u64 > ,
710
710
711
711
/// The order of the documents for the purposes of the operation.
@@ -791,14 +791,14 @@ pub struct FindOneOptions {
791
791
///
792
792
/// Note: this option is deprecated starting in MongoDB version 4.0 and removed in MongoDB 4.2.
793
793
/// 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" ) ]
795
795
pub max_scan : Option < u64 > ,
796
796
797
797
/// The maximum amount of time to allow the query to run.
798
798
///
799
799
/// This options maps to the `maxTimeMS` MongoDB query option, so the duration will be sent
800
800
/// 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 " ) ]
802
802
pub max_time : Option < Duration > ,
803
803
804
804
/// The inclusive lower bound for a specific index.
@@ -824,7 +824,7 @@ pub struct FindOneOptions {
824
824
pub show_record_id : Option < bool > ,
825
825
826
826
/// 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" ) ]
828
828
pub skip : Option < u64 > ,
829
829
830
830
/// The order of the documents for the purposes of the operation.
0 commit comments