@@ -25,8 +25,8 @@ use std::fmt::{self, Display, Debug};
2525
2626use chrono:: { DateTime , Timelike , UTC } ;
2727use chrono:: offset:: TimeZone ;
28- use data_encoding:: hex;
2928use serde_json:: Value ;
29+ use hex:: { FromHex , ToHex } ;
3030
3131use oid;
3232use ordered:: OrderedDocument ;
@@ -100,9 +100,7 @@ impl Debug for Bson {
100100
101101 write ! ( f, "TimeStamp({}, {})" , time, inc)
102102 }
103- & Bson :: Binary ( t, ref vec) => {
104- write ! ( f, "BinData({}, 0x{})" , u8 :: from( t) , hex:: encode( vec) )
105- }
103+ & Bson :: Binary ( t, ref vec) => write ! ( f, "BinData({}, 0x{})" , u8 :: from( t) , vec. to_hex( ) ) ,
106104 & Bson :: ObjectId ( ref id) => write ! ( f, "ObjectId({:?})" , id) ,
107105 & Bson :: UtcDatetime ( date_time) => write ! ( f, "UtcDatetime({:?})" , date_time) ,
108106 & Bson :: Symbol ( ref sym) => write ! ( f, "Symbol({:?})" , sym) ,
@@ -145,7 +143,7 @@ impl Display for Bson {
145143 write ! ( fmt, "Timestamp({}, {})" , time, inc)
146144 }
147145 & Bson :: Binary ( t, ref vec) => {
148- write ! ( fmt, "BinData({}, 0x{})" , u8 :: from( t) , hex :: encode ( vec) )
146+ write ! ( fmt, "BinData({}, 0x{})" , u8 :: from( t) , vec. to_hex ( ) )
149147 }
150148 & Bson :: ObjectId ( ref id) => write ! ( fmt, "ObjectId(\" {}\" )" , id) ,
151149 & Bson :: UtcDatetime ( date_time) => write ! ( fmt, "Date(\" {}\" )" , date_time) ,
@@ -325,7 +323,7 @@ impl Bson {
325323 let tval: u8 = From :: from ( t) ;
326324 json ! ( {
327325 "type" : tval,
328- "$binary" : hex :: encode ( v )
326+ "$binary" : v . to_hex ( )
329327 } )
330328 }
331329 & Bson :: ObjectId ( ref v) => json ! ( { "$oid" : v. to_string( ) } ) ,
@@ -396,7 +394,7 @@ impl Bson {
396394 Bson :: Binary ( t, ref v) => {
397395 let tval: u8 = From :: from ( t) ;
398396 doc ! {
399- "$binary" => ( hex :: encode ( v ) ) ,
397+ "$binary" => ( v . to_hex ( ) ) ,
400398 "type" => ( tval as i64 )
401399 }
402400 }
@@ -444,7 +442,7 @@ impl Bson {
444442 } else if let ( Ok ( hex) , Ok ( t) ) = ( values. get_str ( "$binary" ) , values. get_i64 ( "type" ) ) {
445443 let ttype = t as u8 ;
446444 return Bson :: Binary ( From :: from ( ttype) ,
447- hex :: decode ( hex. to_uppercase ( ) . as_bytes ( ) ) . unwrap ( ) ) ;
445+ FromHex :: from_hex ( hex. as_bytes ( ) ) . unwrap ( ) ) ;
448446 }
449447
450448 } else if values. len ( ) == 1 {
0 commit comments