@@ -30,13 +30,16 @@ use serde::{
30
30
de:: { Error , Unexpected } ,
31
31
Deserialize ,
32
32
Deserializer ,
33
+ Serialize ,
33
34
} ;
35
+ use serde_with:: skip_serializing_none;
34
36
use strsim:: jaro_winkler;
35
37
use typed_builder:: TypedBuilder ;
36
38
use webpki_roots:: TLS_SERVER_ROOTS ;
37
39
38
40
use crate :: {
39
41
bson:: { doc, Bson , Document } ,
42
+ bson_util:: { deserialize_duration_from_u64_millis, serialize_duration_as_int_millis} ,
40
43
client:: auth:: { AuthMechanism , Credential } ,
41
44
concern:: { Acknowledgment , ReadConcern , WriteConcern } ,
42
45
error:: { ErrorKind , Result } ,
@@ -2146,4 +2149,47 @@ mod tests {
2146
2149
/// [`ClientSession`](../struct.ClientSession.html).
2147
2150
#[ derive( Clone , Debug , Deserialize , TypedBuilder ) ]
2148
2151
#[ builder( field_defaults( default , setter( strip_option) ) ) ]
2149
- pub struct SessionOptions { }
2152
+ #[ serde( rename_all = "camelCase" ) ]
2153
+ #[ non_exhaustive]
2154
+ pub struct SessionOptions {
2155
+ /// The default options to use for transactions started on this session.
2156
+ ///
2157
+ /// If these options are not specified, they will be inherited from the
2158
+ /// [`Client`](../struct.Client.html) associated with this session. They will not
2159
+ /// be inherited from the options specified
2160
+ /// on the [`Database`](../struct.Database.html) or [`Collection`](../struct.Collection.html)
2161
+ /// associated with the operations within the transaction.
2162
+ pub default_transaction_options : Option < TransactionOptions > ,
2163
+ }
2164
+
2165
+ /// Contains the options that can be used for a transaction.
2166
+ #[ skip_serializing_none]
2167
+ #[ derive( Debug , Default , Serialize , Deserialize , TypedBuilder , Clone ) ]
2168
+ #[ builder( field_defaults( default , setter( strip_option) ) ) ]
2169
+ #[ serde( rename_all = "camelCase" ) ]
2170
+ #[ non_exhaustive]
2171
+ pub struct TransactionOptions {
2172
+ /// The read concern to use for the transaction.
2173
+ #[ builder( default ) ]
2174
+ #[ serde( skip_serializing) ]
2175
+ pub read_concern : Option < ReadConcern > ,
2176
+
2177
+ /// The write concern to use when committing or aborting a transaction.
2178
+ #[ builder( default ) ]
2179
+ pub write_concern : Option < WriteConcern > ,
2180
+
2181
+ /// The selection criteria to use for all read operations in a transaction.
2182
+ #[ builder( default ) ]
2183
+ #[ serde( skip_serializing, rename = "readPreference" ) ]
2184
+ pub selection_criteria : Option < SelectionCriteria > ,
2185
+
2186
+ /// The maximum amount of time to allow a single commitTransaction to run.
2187
+ #[ builder( default ) ]
2188
+ #[ serde(
2189
+ serialize_with = "serialize_duration_as_int_millis" ,
2190
+ deserialize_with = "deserialize_duration_from_u64_millis" ,
2191
+ rename( serialize = "maxTimeMS" , deserialize = "maxCommitTimeMS" ) ,
2192
+ default
2193
+ ) ]
2194
+ pub max_commit_time : Option < Duration > ,
2195
+ }
0 commit comments