File tree Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Expand file tree Collapse file tree 1 file changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ use crate::storage::{compression::CompressionAlgorithm, FileRange};
3
3
use anyhow:: { bail, Context as _} ;
4
4
use serde:: { Deserialize , Serialize } ;
5
5
use std:: collections:: HashMap ;
6
- use std:: io;
6
+ use std:: io:: { self , Write } ;
7
7
use std:: path:: { Path , PathBuf } ;
8
8
9
9
#[ derive( Deserialize , Serialize ) ]
@@ -28,11 +28,14 @@ pub(crate) struct Index {
28
28
29
29
impl Index {
30
30
pub ( crate ) fn load ( reader : impl io:: Read ) -> Result < Index > {
31
- serde_cbor:: from_reader ( reader) . context ( "deserialization error" )
31
+ serde_cbor:: from_reader ( io :: BufReader :: new ( reader) ) . context ( "deserialization error" )
32
32
}
33
33
34
34
pub ( crate ) fn save ( & self , writer : impl io:: Write ) -> Result < ( ) > {
35
- serde_cbor:: to_writer ( writer, self ) . context ( "serialization error" )
35
+ let mut buf = io:: BufWriter :: new ( writer) ;
36
+ serde_cbor:: to_writer ( & mut buf, self ) . context ( "serialization error" ) ?;
37
+ buf. flush ( ) ?;
38
+ Ok ( ( ) )
36
39
}
37
40
38
41
pub ( crate ) fn new_from_zip < R : io:: Read + io:: Seek > ( zipfile : & mut R ) -> Result < Index > {
You can’t perform that action at this time.
0 commit comments