@@ -271,72 +271,12 @@ impl<'de> Visitor<'de> for SeededVisitor<'_, 'de> {
271271 Ok ( ElementType :: Array )
272272 }
273273 // Cases that don't
274- _ => match bson. as_ref ( ) {
275- RawBsonRef :: ObjectId ( oid) => {
276- self . buffer . append_bytes ( & oid. bytes ( ) ) ;
277- Ok ( ElementType :: ObjectId )
278- }
279- RawBsonRef :: Symbol ( s) => {
280- self . append_string ( s) ;
281- Ok ( ElementType :: Symbol )
282- }
283- RawBsonRef :: Decimal128 ( d) => {
284- self . buffer . append_bytes ( & d. bytes ) ;
285- Ok ( ElementType :: Decimal128 )
286- }
287- RawBsonRef :: RegularExpression ( re) => {
288- self . append_cstring ( re. pattern )
289- . map_err ( SerdeError :: custom) ?;
290- self . append_cstring ( re. options )
291- . map_err ( SerdeError :: custom) ?;
292- Ok ( ElementType :: RegularExpression )
293- }
294- RawBsonRef :: Undefined => Ok ( ElementType :: Undefined ) ,
295- RawBsonRef :: DateTime ( dt) => {
296- self . buffer
297- . append_bytes ( & dt. timestamp_millis ( ) . to_le_bytes ( ) ) ;
298- Ok ( ElementType :: DateTime )
299- }
300- RawBsonRef :: Timestamp ( ts) => {
301- self . buffer . append_bytes ( & ts. increment . to_le_bytes ( ) ) ;
302- self . buffer . append_bytes ( & ts. time . to_le_bytes ( ) ) ;
303- Ok ( ElementType :: Timestamp )
304- }
305- RawBsonRef :: MinKey => Ok ( ElementType :: MinKey ) ,
306- RawBsonRef :: MaxKey => Ok ( ElementType :: MaxKey ) ,
307- RawBsonRef :: JavaScriptCode ( s) => {
308- self . append_string ( s) ;
309- Ok ( ElementType :: JavaScriptCode )
310- }
311- RawBsonRef :: JavaScriptCodeWithScope ( jsc) => {
312- let length_index = self . pad_document_length ( ) ;
313- self . append_string ( jsc. code ) ;
314- self . buffer . append_bytes ( jsc. scope . as_bytes ( ) ) ;
315-
316- let length_bytes =
317- ( ( self . buffer . len ( ) - length_index) as i32 ) . to_le_bytes ( ) ;
318- self . buffer
319- . copy_from_slice ( length_index..length_index + 4 , & length_bytes) ;
320-
321- Ok ( ElementType :: JavaScriptCodeWithScope )
322- }
323- RawBsonRef :: DbPointer ( dbp) => {
324- self . append_string ( dbp. namespace ) ;
325- self . buffer . append_bytes ( & dbp. id . bytes ( ) ) ;
326- Ok ( ElementType :: DbPointer )
327- }
328- RawBsonRef :: Double ( d) => self . visit_f64 ( d) ,
329- RawBsonRef :: String ( s) => self . visit_str ( s) ,
330- RawBsonRef :: Boolean ( b) => self . visit_bool ( b) ,
331- RawBsonRef :: Null => self . visit_none ( ) ,
332- RawBsonRef :: Int32 ( i) => self . visit_i32 ( i) ,
333- RawBsonRef :: Int64 ( i) => self . visit_i64 ( i) ,
334- // These are always borrowed and are handled
335- // at the top of the outer `match`.
336- RawBsonRef :: Array ( _) | RawBsonRef :: Document ( _) | RawBsonRef :: Binary ( _) => {
337- unreachable ! ( )
338- }
339- } ,
274+ _ => {
275+ let bson = bson. as_ref ( ) ;
276+ bson. append_to ( self . buffer . get_owned_buffer ( ) )
277+ . map_err ( A :: Error :: custom) ?;
278+ Ok ( bson. element_type ( ) )
279+ }
340280 }
341281 }
342282 MapParse :: Aggregate ( first_key) => {
0 commit comments