@@ -143,6 +143,7 @@ struct CollectionInner {
143
143
selection_criteria : Option < SelectionCriteria > ,
144
144
read_concern : Option < ReadConcern > ,
145
145
write_concern : Option < WriteConcern > ,
146
+ human_readable_serialization : bool ,
146
147
}
147
148
148
149
impl < T > Collection < T > {
@@ -157,6 +158,7 @@ impl<T> Collection<T> {
157
158
let write_concern = options
158
159
. write_concern
159
160
. or_else ( || db. write_concern ( ) . cloned ( ) ) ;
161
+ let human_readable_serialization = options. human_readable_serialization . unwrap_or_default ( ) ;
160
162
161
163
Self {
162
164
inner : Arc :: new ( CollectionInner {
@@ -166,6 +168,7 @@ impl<T> Collection<T> {
166
168
selection_criteria,
167
169
read_concern,
168
170
write_concern,
171
+ human_readable_serialization,
169
172
} ) ,
170
173
_phantom : Default :: default ( ) ,
171
174
}
@@ -1119,14 +1122,16 @@ where
1119
1122
options : impl Into < Option < FindOneAndReplaceOptions > > ,
1120
1123
session : impl Into < Option < & mut ClientSession > > ,
1121
1124
) -> Result < Option < T > > {
1125
+ let mut options = options. into ( ) ;
1122
1126
let replacement = to_document_with_options (
1123
1127
replacement. borrow ( ) ,
1124
- SerializerOptions :: builder ( ) . human_readable ( false ) . build ( ) ,
1128
+ SerializerOptions :: builder ( )
1129
+ . human_readable ( self . inner . human_readable_serialization )
1130
+ . build ( ) ,
1125
1131
) ?;
1126
1132
1127
1133
let session = session. into ( ) ;
1128
1134
1129
- let mut options = options. into ( ) ;
1130
1135
resolve_write_concern_with_session ! ( self , options, session. as_ref( ) ) ?;
1131
1136
1132
1137
let op = FindAndModify :: < T > :: with_replace ( self . namespace ( ) , filter, replacement, options) ?;
@@ -1205,7 +1210,13 @@ where
1205
1210
1206
1211
while n_attempted < ds. len ( ) {
1207
1212
let docs: Vec < & T > = ds. iter ( ) . skip ( n_attempted) . map ( Borrow :: borrow) . collect ( ) ;
1208
- let insert = Insert :: new_encrypted ( self . namespace ( ) , docs, options. clone ( ) , encrypted) ;
1213
+ let insert = Insert :: new_encrypted (
1214
+ self . namespace ( ) ,
1215
+ docs,
1216
+ options. clone ( ) ,
1217
+ encrypted,
1218
+ self . inner . human_readable_serialization ,
1219
+ ) ;
1209
1220
1210
1221
match self
1211
1222
. client ( )
@@ -1332,6 +1343,7 @@ where
1332
1343
self . namespace ( ) ,
1333
1344
vec ! [ doc] ,
1334
1345
options. map ( InsertManyOptions :: from_insert_one_options) ,
1346
+ self . inner . human_readable_serialization ,
1335
1347
) ;
1336
1348
self . client ( )
1337
1349
. execute_operation ( insert, session)
@@ -1382,16 +1394,18 @@ where
1382
1394
options : impl Into < Option < ReplaceOptions > > ,
1383
1395
session : impl Into < Option < & mut ClientSession > > ,
1384
1396
) -> Result < UpdateResult > {
1397
+ let mut options = options. into ( ) ;
1385
1398
let replacement = to_document_with_options (
1386
1399
replacement. borrow ( ) ,
1387
- SerializerOptions :: builder ( ) . human_readable ( false ) . build ( ) ,
1400
+ SerializerOptions :: builder ( )
1401
+ . human_readable ( self . inner . human_readable_serialization )
1402
+ . build ( ) ,
1388
1403
) ?;
1389
1404
1390
1405
bson_util:: replacement_document_check ( & replacement) ?;
1391
1406
1392
1407
let session = session. into ( ) ;
1393
1408
1394
- let mut options = options. into ( ) ;
1395
1409
resolve_write_concern_with_session ! ( self , options, session. as_ref( ) ) ?;
1396
1410
1397
1411
let update = Update :: new (
0 commit comments