@@ -79,17 +79,18 @@ fn main() -> Result<(), Box<dyn Error>> {
7979
8080 let start = Instant :: now ( ) ;
8181 let file = File :: create ( "./examples/geonames-tree.bincode.gz" ) ?;
82- let encoder = GzEncoder :: new ( file, Compression :: default ( ) ) ;
83- bincode:: serialize_into ( encoder , & kdtree ) ?;
82+ let mut encoder = GzEncoder :: new ( file, Compression :: default ( ) ) ;
83+ bincode:: serde :: encode_into_std_write ( & kdtree , & mut encoder , bincode :: config :: standard ( ) ) ?;
8484 println ! (
8585 "Serialized k-d tree to gzipped bincode file ({})" ,
8686 ElapsedDuration :: new( start. elapsed( ) )
8787 ) ;
8888
8989 let start = Instant :: now ( ) ;
9090 let file = File :: open ( "./examples/geonames-tree.bincode.gz" ) ?;
91- let decompressor = GzDecoder :: new ( file) ;
92- let deserialized_tree: Tree = bincode:: deserialize_from ( decompressor) ?;
91+ let mut decompressor = GzDecoder :: new ( file) ;
92+ let deserialized_tree: Tree =
93+ bincode:: serde:: decode_from_std_read ( & mut decompressor, bincode:: config:: standard ( ) ) ?;
9394 println ! (
9495 "Deserialized gzipped bincode file back into a k-d tree ({})" ,
9596 ElapsedDuration :: new( start. elapsed( ) )
@@ -113,18 +114,18 @@ fn main() -> Result<(), Box<dyn Error>> {
113114
114115 let start = Instant :: now ( ) ;
115116 let file = File :: create ( "./examples/geonames-immutable-tree.bincode.gz" ) ?;
116- let encoder = GzEncoder :: new ( file, Compression :: default ( ) ) ;
117- bincode:: serialize_into ( encoder , & kdtree ) ?;
117+ let mut encoder = GzEncoder :: new ( file, Compression :: default ( ) ) ;
118+ bincode:: serde :: encode_into_std_write ( & kdtree , & mut encoder , bincode :: config :: standard ( ) ) ?;
118119 println ! (
119120 "Serialized k-d tree to gzipped bincode file ({})" ,
120121 ElapsedDuration :: new( start. elapsed( ) )
121122 ) ;
122123
123124 let start = Instant :: now ( ) ;
124125 let file = File :: open ( "./examples/geonames-immutable-tree.bincode.gz" ) ?;
125- let decompressor = GzDecoder :: new ( file) ;
126+ let mut decompressor = GzDecoder :: new ( file) ;
126127 let deserialized_tree: ImmutableKdTree < f32 , u32 , 3 , 32 > =
127- bincode:: deserialize_from ( decompressor) ?;
128+ bincode:: serde :: decode_from_std_read ( & mut decompressor, bincode :: config :: standard ( ) ) ?;
128129 println ! (
129130 "Deserialized gzipped bincode file back into a k-d tree ({})" ,
130131 ElapsedDuration :: new( start. elapsed( ) )
0 commit comments