@@ -258,13 +258,13 @@ pub(crate) struct ServerApi {
258
258
259
259
/// Whether the MongoDB server should reject all commands that are not part of the
260
260
/// declared API version. This includes command options and aggregation pipeline stages.
261
- #[ builder( default ) ]
261
+ #[ builder( default , setter ( strip_option ) ) ]
262
262
pub strict : Option < bool > ,
263
263
264
264
/// Whether the MongoDB server should return command failures when functionality that is
265
265
/// deprecated from the declared API version is used.
266
266
/// Note that at the time of this writing, no deprecations in version 1 exist.
267
- #[ builder( default ) ]
267
+ #[ builder( default , setter ( strip_option ) ) ]
268
268
pub deprecation_errors : Option < bool > ,
269
269
}
270
270
@@ -289,54 +289,54 @@ pub struct ClientOptions {
289
289
/// The application name that the Client will send to the server as part of the handshake. This
290
290
/// can be used in combination with the server logs to determine which Client is connected to a
291
291
/// server.
292
- #[ builder( default ) ]
292
+ #[ builder( default , setter ( strip_option ) ) ]
293
293
pub app_name : Option < String > ,
294
294
295
- #[ builder( default ) ]
295
+ #[ builder( default , setter ( skip ) ) ]
296
296
pub ( crate ) compressors : Option < Vec < String > > ,
297
297
298
298
/// The handler that should process all Connection Monitoring and Pooling events. See the
299
299
/// CmapEventHandler type documentation for more details.
300
300
#[ derivative( Debug = "ignore" , PartialEq = "ignore" ) ]
301
- #[ builder( default ) ]
301
+ #[ builder( default , setter ( strip_option ) ) ]
302
302
#[ serde( skip) ]
303
303
pub cmap_event_handler : Option < Arc < dyn CmapEventHandler > > ,
304
304
305
305
/// The handler that should process all command-related events. See the CommandEventHandler
306
306
/// type documentation for more details.
307
307
#[ derivative( Debug = "ignore" , PartialEq = "ignore" ) ]
308
- #[ builder( default ) ]
308
+ #[ builder( default , setter ( strip_option ) ) ]
309
309
#[ serde( skip) ]
310
310
pub command_event_handler : Option < Arc < dyn CommandEventHandler > > ,
311
311
312
312
/// The connect timeout passed to each underlying TcpStream when attemtping to connect to the
313
313
/// server.
314
314
///
315
315
/// The default value is 10 seconds.
316
- #[ builder( default ) ]
316
+ #[ builder( default , setter ( strip_option ) ) ]
317
317
pub connect_timeout : Option < Duration > ,
318
318
319
319
/// The credential to use for authenticating connections made by this client.
320
- #[ builder( default ) ]
320
+ #[ builder( default , setter ( strip_option ) ) ]
321
321
pub credential : Option < Credential > ,
322
322
323
323
/// Specifies whether the Client should directly connect to a single host rather than
324
324
/// autodiscover all servers in the cluster.
325
325
///
326
326
/// The default value is false.
327
- #[ builder( default ) ]
327
+ #[ builder( default , setter ( strip_option ) ) ]
328
328
pub direct_connection : Option < bool > ,
329
329
330
330
/// Extra information to append to the driver version in the metadata of the handshake with the
331
331
/// server. This should be used by libraries wrapping the driver, e.g. ODMs.
332
- #[ builder( default ) ]
332
+ #[ builder( default , setter ( strip_option ) ) ]
333
333
pub driver_info : Option < DriverInfo > ,
334
334
335
335
/// The amount of time each monitoring thread should wait between sending an isMaster command
336
336
/// to its respective server.
337
337
///
338
338
/// The default value is 10 seconds.
339
- #[ builder( default ) ]
339
+ #[ builder( default , setter ( strip_option ) ) ]
340
340
pub heartbeat_freq : Option < Duration > ,
341
341
342
342
/// When running a read operation with a ReadPreference that allows selecting secondaries,
@@ -350,14 +350,14 @@ pub struct ClientOptions {
350
350
/// lowest average round trip time is eligible.
351
351
///
352
352
/// The default value is 15 ms.
353
- #[ builder( default ) ]
353
+ #[ builder( default , setter ( strip_option ) ) ]
354
354
pub local_threshold : Option < Duration > ,
355
355
356
356
/// The amount of time that a connection can remain idle in a connection pool before being
357
357
/// closed. A value of zero indicates that connections should not be closed due to being idle.
358
358
///
359
359
/// By default, connections will not be closed due to being idle.
360
- #[ builder( default ) ]
360
+ #[ builder( default , setter ( strip_option ) ) ]
361
361
pub max_idle_time : Option < Duration > ,
362
362
363
363
/// The maximum amount of connections that the Client should allow to be created in a
@@ -366,41 +366,41 @@ pub struct ClientOptions {
366
366
/// operation finishes and its connection is checked back into the pool.
367
367
///
368
368
/// The default value is 100.
369
- #[ builder( default ) ]
369
+ #[ builder( default , setter ( strip_option ) ) ]
370
370
pub max_pool_size : Option < u32 > ,
371
371
372
372
/// The minimum number of connections that should be available in a server's connection pool at
373
373
/// a given time. If fewer than `min_pool_size` connections are in the pool, connections will
374
374
/// be added to the pool in the background until `min_pool_size` is reached.
375
375
///
376
376
/// The default value is 0.
377
- #[ builder( default ) ]
377
+ #[ builder( default , setter ( strip_option ) ) ]
378
378
pub min_pool_size : Option < u32 > ,
379
379
380
380
/// Specifies the default read concern for operations performed on the Client. See the
381
381
/// ReadConcern type documentation for more details.
382
- #[ builder( default ) ]
382
+ #[ builder( default , setter ( strip_option ) ) ]
383
383
pub read_concern : Option < ReadConcern > ,
384
384
385
385
/// The name of the replica set that the Client should connect to.
386
- #[ builder( default ) ]
386
+ #[ builder( default , setter ( strip_option ) ) ]
387
387
pub repl_set_name : Option < String > ,
388
388
389
389
/// Whether or not the client should retry a read operation if the operation fails.
390
390
///
391
391
/// The default value is true.
392
- #[ builder( default ) ]
392
+ #[ builder( default , setter ( strip_option ) ) ]
393
393
pub retry_reads : Option < bool > ,
394
394
395
395
/// Whether or not the client should retry a write operation if the operation fails.
396
396
///
397
397
/// The default value is true.
398
- #[ builder( default ) ]
398
+ #[ builder( default , setter ( strip_option ) ) ]
399
399
pub retry_writes : Option < bool > ,
400
400
401
401
/// The default selection criteria for operations performed on the Client. See the
402
402
/// SelectionCriteria type documentation for more details.
403
- #[ builder( default ) ]
403
+ #[ builder( default , setter ( strip_option ) ) ]
404
404
pub selection_criteria : Option < SelectionCriteria > ,
405
405
406
406
/// The declared API version for this client.
@@ -412,58 +412,59 @@ pub struct ClientOptions {
412
412
/// supported and is considered undefined behaviour. To run any command with a different API
413
413
/// version or without declaring one, create a separate client that declares the
414
414
/// appropriate API version.
415
- #[ builder( default , skip) ]
415
+ #[ builder( default , setter ( skip) ) ]
416
416
pub ( crate ) server_api : Option < ServerApi > ,
417
417
418
418
/// The amount of time the Client should attempt to select a server for an operation before
419
419
/// timing outs
420
420
///
421
421
/// The default value is 30 seconds.
422
- #[ builder( default ) ]
422
+ #[ builder( default , setter ( strip_option ) ) ]
423
423
pub server_selection_timeout : Option < Duration > ,
424
424
425
- #[ builder( default ) ]
425
+ #[ builder( default , setter ( skip ) ) ]
426
426
pub ( crate ) socket_timeout : Option < Duration > ,
427
427
428
428
/// The TLS configuration for the Client to use in its connections with the server.
429
429
///
430
430
/// By default, TLS is disabled.
431
- #[ builder( default ) ]
431
+ #[ builder( default , setter ( strip_option ) ) ]
432
432
pub tls : Option < Tls > ,
433
433
434
434
/// The amount of time a thread should block while waiting to check out a connection before
435
435
/// returning an error. Note that if there are fewer than `max_pool_size` connections checked
436
436
/// out or if a connection is available in the pool, checking out a connection will not block.
437
437
///
438
438
/// By default, threads will wait indefinitely for a connection to become available.
439
- #[ builder( default ) ]
439
+ #[ builder( default , setter ( strip_option ) ) ]
440
440
pub wait_queue_timeout : Option < Duration > ,
441
441
442
442
/// Specifies the default write concern for operations performed on the Client. See the
443
443
/// WriteConcern type documentation for more details.
444
- #[ builder( default ) ]
444
+ #[ builder( default , setter ( strip_option ) ) ]
445
445
pub write_concern : Option < WriteConcern > ,
446
446
447
- #[ builder( default ) ]
447
+ #[ builder( default , setter ( skip ) ) ]
448
448
pub ( crate ) zlib_compression : Option < i32 > ,
449
449
450
- #[ builder( default ) ]
450
+ #[ builder( default , setter ( skip ) ) ]
451
451
pub ( crate ) original_srv_hostname : Option < String > ,
452
452
453
- #[ builder( default ) ]
453
+ #[ builder( default , setter ( skip ) ) ]
454
454
pub ( crate ) original_uri : Option < String > ,
455
455
456
456
/// Configuration of the trust-dns resolver used for SRV and TXT lookups.
457
457
/// By default, the host system's resolver configuration will be used.
458
458
///
459
459
/// On Windows, there is a known performance issue in trust-dns with using the default system
460
460
/// configuration, so a custom configuration is recommended.
461
- #[ builder( default ) ]
461
+ #[ builder( default , setter ( skip ) ) ]
462
462
#[ serde( skip) ]
463
463
pub ( crate ) resolver_config : Option < ResolverConfig > ,
464
464
465
465
/// Used by tests to override MIN_HEARTBEAT_FREQUENCY.
466
- #[ builder( default ) ]
466
+ #[ builder( default , setter( strip_option) ) ]
467
+ #[ cfg( test) ]
467
468
pub ( crate ) heartbeat_freq_test : Option < Duration > ,
468
469
}
469
470
@@ -540,27 +541,25 @@ impl From<TlsOptions> for Option<Tls> {
540
541
541
542
/// Specifies the TLS configuration that the [`Client`](../struct.Client.html) should use.
542
543
#[ derive( Clone , Debug , Default , Deserialize , PartialEq , TypedBuilder ) ]
544
+ #[ builder( field_defaults( default , setter( strip_option) ) ) ]
543
545
#[ non_exhaustive]
544
546
pub struct TlsOptions {
545
547
/// Whether or not the [`Client`](../struct.Client.html) should return an error if the server
546
548
/// presents an invalid certificate. This setting should _not_ be set to `true` in
547
549
/// production; it should only be used for testing.
548
550
///
549
551
/// The default value is to error when the server presents an invalid certificate.
550
- #[ builder( default ) ]
551
552
pub allow_invalid_certificates : Option < bool > ,
552
553
553
554
/// The path to the CA file that the [`Client`](../struct.Client.html) should use for TLS. If
554
555
/// none is specified, then the driver will use the Mozilla root certificates from the
555
556
/// `webpki-roots` crate.
556
- #[ builder( default ) ]
557
557
pub ca_file_path : Option < String > ,
558
558
559
559
/// The path to the certificate file that the [`Client`](../struct.Client.html) should present
560
560
/// to the server to verify its identify. If none is specified, then the
561
561
/// [`Client`](../struct.Client.html) will not attempt to verify its identity to the
562
562
/// server.
563
- #[ builder( default ) ]
564
563
pub cert_key_file_path : Option < String > ,
565
564
}
566
565
@@ -645,11 +644,11 @@ pub struct DriverInfo {
645
644
pub name : String ,
646
645
647
646
/// The version of the library wrapping the driver.
648
- #[ builder( default ) ]
647
+ #[ builder( default , setter ( strip_option ) ) ]
649
648
pub version : Option < String > ,
650
649
651
650
/// Optional platform information for the wrapping driver.
652
- #[ builder( default ) ]
651
+ #[ builder( default , setter ( strip_option ) ) ]
653
652
pub platform : Option < String > ,
654
653
}
655
654
@@ -684,8 +683,9 @@ impl From<ClientOptionsParser> for ClientOptions {
684
683
original_srv_hostname : None ,
685
684
original_uri : Some ( parser. original_uri ) ,
686
685
resolver_config : None ,
687
- heartbeat_freq_test : None ,
688
686
server_api : None ,
687
+ #[ cfg( test) ]
688
+ heartbeat_freq_test : None ,
689
689
}
690
690
}
691
691
}
@@ -2070,4 +2070,5 @@ mod tests {
2070
2070
/// Contains the options that can be used to create a new
2071
2071
/// [`ClientSession`](../struct.ClientSession.html).
2072
2072
#[ derive( Clone , Debug , Deserialize , TypedBuilder ) ]
2073
+ #[ builder( field_defaults( default , setter( strip_option) ) ) ]
2073
2074
pub struct SessionOptions { }
0 commit comments