@@ -143,6 +143,7 @@ struct CollectionInner {
143143 selection_criteria : Option < SelectionCriteria > ,
144144 read_concern : Option < ReadConcern > ,
145145 write_concern : Option < WriteConcern > ,
146+ human_readable_serialization : bool ,
146147}
147148
148149impl < T > Collection < T > {
@@ -157,6 +158,7 @@ impl<T> Collection<T> {
157158 let write_concern = options
158159 . write_concern
159160 . or_else ( || db. write_concern ( ) . cloned ( ) ) ;
161+ let human_readable_serialization = options. human_readable_serialization . unwrap_or_default ( ) ;
160162
161163 Self {
162164 inner : Arc :: new ( CollectionInner {
@@ -166,6 +168,7 @@ impl<T> Collection<T> {
166168 selection_criteria,
167169 read_concern,
168170 write_concern,
171+ human_readable_serialization,
169172 } ) ,
170173 _phantom : Default :: default ( ) ,
171174 }
@@ -1119,14 +1122,16 @@ where
11191122 options : impl Into < Option < FindOneAndReplaceOptions > > ,
11201123 session : impl Into < Option < & mut ClientSession > > ,
11211124 ) -> Result < Option < T > > {
1125+ let mut options = options. into ( ) ;
11221126 let replacement = to_document_with_options (
11231127 replacement. borrow ( ) ,
1124- SerializerOptions :: builder ( ) . human_readable ( false ) . build ( ) ,
1128+ SerializerOptions :: builder ( )
1129+ . human_readable ( self . inner . human_readable_serialization )
1130+ . build ( ) ,
11251131 ) ?;
11261132
11271133 let session = session. into ( ) ;
11281134
1129- let mut options = options. into ( ) ;
11301135 resolve_write_concern_with_session ! ( self , options, session. as_ref( ) ) ?;
11311136
11321137 let op = FindAndModify :: < T > :: with_replace ( self . namespace ( ) , filter, replacement, options) ?;
@@ -1205,7 +1210,13 @@ where
12051210
12061211 while n_attempted < ds. len ( ) {
12071212 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+ ) ;
12091220
12101221 match self
12111222 . client ( )
@@ -1332,6 +1343,7 @@ where
13321343 self . namespace ( ) ,
13331344 vec ! [ doc] ,
13341345 options. map ( InsertManyOptions :: from_insert_one_options) ,
1346+ self . inner . human_readable_serialization ,
13351347 ) ;
13361348 self . client ( )
13371349 . execute_operation ( insert, session)
@@ -1382,16 +1394,18 @@ where
13821394 options : impl Into < Option < ReplaceOptions > > ,
13831395 session : impl Into < Option < & mut ClientSession > > ,
13841396 ) -> Result < UpdateResult > {
1397+ let mut options = options. into ( ) ;
13851398 let replacement = to_document_with_options (
13861399 replacement. borrow ( ) ,
1387- SerializerOptions :: builder ( ) . human_readable ( false ) . build ( ) ,
1400+ SerializerOptions :: builder ( )
1401+ . human_readable ( self . inner . human_readable_serialization )
1402+ . build ( ) ,
13881403 ) ?;
13891404
13901405 bson_util:: replacement_document_check ( & replacement) ?;
13911406
13921407 let session = session. into ( ) ;
13931408
1394- let mut options = options. into ( ) ;
13951409 resolve_write_concern_with_session ! ( self , options, session. as_ref( ) ) ?;
13961410
13971411 let update = Update :: new (
0 commit comments