@@ -15,6 +15,7 @@ use crate::{
1515/// These are the valid options for creating a [`Collection`](../struct.Collection.html) with
1616/// [`Database::collection_with_options`](../struct.Database.html#method.collection_with_options).
1717#[ derive( Debug , Default , TypedBuilder ) ]
18+ #[ non_exhaustive]
1819pub struct CollectionOptions {
1920 /// The default read preference for operations.
2021 #[ builder( default ) ]
@@ -34,6 +35,7 @@ pub struct CollectionOptions {
3435/// [`Collection::find_one_and_update`](../struct.Collection.html#method.find_one_and_update)
3536/// operation should return the document before or after modification.
3637#[ derive( Debug ) ]
38+ #[ non_exhaustive]
3739pub enum ReturnDocument {
3840 /// Return the document after modification.
3941 After ,
@@ -44,6 +46,7 @@ pub enum ReturnDocument {
4446/// Specifies the index to use for an operation.
4547#[ derive( Clone , Debug , Deserialize , Serialize ) ]
4648#[ serde( untagged) ]
49+ #[ non_exhaustive]
4750pub enum Hint {
4851 /// Specifies the keys of the index to use.
4952 Keys ( Document ) ,
@@ -62,6 +65,7 @@ impl Hint {
6265
6366/// Specifies the type of cursor to return from a find operation.
6467#[ derive( Debug , Clone , Copy ) ]
68+ #[ non_exhaustive]
6569pub enum CursorType {
6670 /// Default; close the cursor after the last document is received from the server.
6771 NonTailable ,
@@ -78,6 +82,7 @@ pub enum CursorType {
7882/// Specifies the options to a
7983/// [`Collection::insert_one`](../struct.Collection.html#method.insert_one) operation.
8084#[ derive( Clone , Debug , Default , TypedBuilder ) ]
85+ #[ non_exhaustive]
8186pub struct InsertOneOptions {
8287 /// Opt out of document-level validation.
8388 #[ builder( default ) ]
@@ -93,6 +98,7 @@ pub struct InsertOneOptions {
9398#[ skip_serializing_none]
9499#[ derive( Clone , Debug , Default , TypedBuilder , Serialize , Deserialize ) ]
95100#[ serde( rename_all = "camelCase" ) ]
101+ #[ non_exhaustive]
96102pub struct InsertManyOptions {
97103 /// Opt out of document-level validation.
98104 #[ builder( default ) ]
@@ -126,6 +132,7 @@ impl InsertManyOptions {
126132/// [documentation](https://docs.mongodb.com/manual/reference/command/update/#update-command-behaviors)
127133#[ derive( Clone , Debug , Serialize ) ]
128134#[ serde( untagged) ]
135+ #[ non_exhaustive]
129136pub enum UpdateModifications {
130137 /// A document that contains only update operator expressions.
131138 Document ( Document ) ,
@@ -162,6 +169,7 @@ impl From<Vec<Document>> for UpdateModifications {
162169/// [`Collection::update_one`](../struct.Collection.html#method.update_one) or
163170/// [`Collection::update_many`](../struct.Collection.html#method.update_many) operation.
164171#[ derive( Debug , Default , TypedBuilder ) ]
172+ #[ non_exhaustive]
165173pub struct UpdateOptions {
166174 /// A set of filters specifying to which array elements an update should apply.
167175 ///
@@ -213,6 +221,7 @@ impl UpdateOptions {
213221/// Specifies the options to a
214222/// [`Collection::replace_one`](../struct.Collection.html#method.replace_one) operation.
215223#[ derive( Debug , Default , TypedBuilder ) ]
224+ #[ non_exhaustive]
216225pub struct ReplaceOptions {
217226 /// Opt out of document-level validation.
218227 #[ builder( default ) ]
@@ -247,6 +256,7 @@ pub struct ReplaceOptions {
247256#[ serde_with:: skip_serializing_none]
248257#[ derive( Debug , Default , TypedBuilder , Serialize ) ]
249258#[ serde( rename_all = "camelCase" ) ]
259+ #[ non_exhaustive]
250260pub struct DeleteOptions {
251261 /// The collation to use for the operation.
252262 ///
@@ -264,6 +274,7 @@ pub struct DeleteOptions {
264274/// [`Collection::find_one_and_delete`](../struct.Collection.html#method.find_one_and_delete)
265275/// operation.
266276#[ derive( Debug , Default , TypedBuilder ) ]
277+ #[ non_exhaustive]
267278pub struct FindOneAndDeleteOptions {
268279 /// The maximum amount of time to allow the query to run.
269280 ///
@@ -296,6 +307,7 @@ pub struct FindOneAndDeleteOptions {
296307/// [`Collection::find_one_and_replace`](../struct.Collection.html#method.find_one_and_replace)
297308/// operation.
298309#[ derive( Debug , Default , TypedBuilder ) ]
310+ #[ non_exhaustive]
299311pub struct FindOneAndReplaceOptions {
300312 /// Opt out of document-level validation.
301313 #[ builder( default ) ]
@@ -340,6 +352,7 @@ pub struct FindOneAndReplaceOptions {
340352/// [`Collection::find_one_and_update`](../struct.Collection.html#method.find_one_and_update)
341353/// operation.
342354#[ derive( Debug , Default , TypedBuilder ) ]
355+ #[ non_exhaustive]
343356pub struct FindOneAndUpdateOptions {
344357 /// A set of filters specifying to which array elements an update should apply.
345358 ///
@@ -392,6 +405,7 @@ pub struct FindOneAndUpdateOptions {
392405#[ skip_serializing_none]
393406#[ serde( rename_all = "camelCase" ) ]
394407#[ derive( Clone , Debug , Default , TypedBuilder , Serialize ) ]
408+ #[ non_exhaustive]
395409pub struct AggregateOptions {
396410 /// Enables writing to temporary files. When set to true, aggregation stages can write data to
397411 /// the _tmp subdirectory in the dbPath directory.
@@ -473,6 +487,7 @@ pub struct AggregateOptions {
473487/// Specifies the options to a
474488/// [`Collection::count_documents`](../struct.Collection.html#method.count_documents) operation.
475489#[ derive( Debug , Default , TypedBuilder ) ]
490+ #[ non_exhaustive]
476491pub struct CountOptions {
477492 /// The index to use for the operation.
478493 #[ builder( default ) ]
@@ -511,6 +526,7 @@ pub struct CountOptions {
511526#[ serde_with:: skip_serializing_none]
512527#[ derive( Debug , Default , TypedBuilder , Serialize , Clone ) ]
513528#[ serde( rename_all = "camelCase" ) ]
529+ #[ non_exhaustive]
514530pub struct EstimatedDocumentCountOptions {
515531 /// The maximum amount of time to allow the query to run.
516532 ///
@@ -540,6 +556,7 @@ pub struct EstimatedDocumentCountOptions {
540556#[ serde_with:: skip_serializing_none]
541557#[ derive( Debug , Default , TypedBuilder , Serialize , Clone ) ]
542558#[ serde( rename_all = "camelCase" ) ]
559+ #[ non_exhaustive]
543560pub struct DistinctOptions {
544561 /// The maximum amount of time to allow the query to run.
545562 ///
@@ -576,6 +593,7 @@ pub struct DistinctOptions {
576593#[ skip_serializing_none]
577594#[ derive( Debug , Default , TypedBuilder , Serialize ) ]
578595#[ serde( rename_all = "camelCase" ) ]
596+ #[ non_exhaustive]
579597pub struct FindOptions {
580598 /// Enables writing to temporary files by the server. When set to true, the find operation can
581599 /// write data to the _tmp subdirectory in the dbPath directory. Only supported in server
@@ -741,6 +759,7 @@ where
741759/// Specifies the options to a [`Collection::find_one`](../struct.Collection.html#method.find_one)
742760/// operation.
743761#[ derive( Debug , Default , TypedBuilder ) ]
762+ #[ non_exhaustive]
744763pub struct FindOneOptions {
745764 /// If true, partial results will be returned from a mongos rather than an error being
746765 /// returned if one or more shards is down.
@@ -820,6 +839,7 @@ pub struct FindOneOptions {
820839
821840/// Specifies an index to create.
822841#[ derive( Debug , TypedBuilder ) ]
842+ #[ non_exhaustive]
823843pub struct IndexModel {
824844 /// The fields to index, along with their sort order.
825845 pub keys : Document ,
@@ -833,6 +853,7 @@ pub struct IndexModel {
833853/// operation.
834854#[ derive( Debug , Default , TypedBuilder , Serialize ) ]
835855#[ serde( rename_all = "camelCase" ) ]
856+ #[ non_exhaustive]
836857pub struct DropCollectionOptions {
837858 /// The write concern for the operation.
838859 #[ builder( default ) ]
0 commit comments