1- use :: prelude:: * ;
1+ use prelude:: * ;
22
33use std:: path:: { Path , PathBuf } ;
44use std:: fs:: { self , File } ;
@@ -62,7 +62,11 @@ impl StoredBundle {
6262 self . info . id . clone ( )
6363 }
6464
65- pub fn copy_to < P : AsRef < Path > > ( & self , base_path : & Path , path : P ) -> Result < Self , BundleDbError > {
65+ pub fn copy_to < P : AsRef < Path > > (
66+ & self ,
67+ base_path : & Path ,
68+ path : P ,
69+ ) -> Result < Self , BundleDbError > {
6670 let src_path = base_path. join ( & self . path ) ;
6771 let dst_path = path. as_ref ( ) ;
6872 try!( fs:: copy ( & src_path, dst_path) . context ( dst_path) ) ;
@@ -71,7 +75,11 @@ impl StoredBundle {
7175 Ok ( bundle)
7276 }
7377
74- pub fn move_to < P : AsRef < Path > > ( & mut self , base_path : & Path , path : P ) -> Result < ( ) , BundleDbError > {
78+ pub fn move_to < P : AsRef < Path > > (
79+ & mut self ,
80+ base_path : & Path ,
81+ path : P ,
82+ ) -> Result < ( ) , BundleDbError > {
7583 let src_path = base_path. join ( & self . path ) ;
7684 let dst_path = path. as_ref ( ) ;
7785 if fs:: rename ( & src_path, dst_path) . is_err ( ) {
@@ -88,20 +96,24 @@ impl StoredBundle {
8896 let mut header = [ 0u8 ; 8 ] ;
8997 try!( file. read_exact ( & mut header) . map_err ( BundleCacheError :: Read ) ) ;
9098 if header[ ..CACHE_FILE_STRING . len ( ) ] != CACHE_FILE_STRING {
91- return Err ( BundleCacheError :: WrongHeader )
99+ return Err ( BundleCacheError :: WrongHeader ) ;
92100 }
93101 let version = header[ CACHE_FILE_STRING . len ( ) ] ;
94102 if version != CACHE_FILE_VERSION {
95- return Err ( BundleCacheError :: UnsupportedVersion ( version) )
103+ return Err ( BundleCacheError :: UnsupportedVersion ( version) ) ;
96104 }
97105 Ok ( try!( msgpack:: decode_from_stream ( & mut file) ) )
98106 }
99107
100108 pub fn save_list_to < P : AsRef < Path > > ( list : & [ Self ] , path : P ) -> Result < ( ) , BundleCacheError > {
101109 let path = path. as_ref ( ) ;
102110 let mut file = BufWriter :: new ( try!( File :: create ( path) . map_err ( BundleCacheError :: Write ) ) ) ;
103- try!( file. write_all ( & CACHE_FILE_STRING ) . map_err ( BundleCacheError :: Write ) ) ;
104- try!( file. write_all ( & [ CACHE_FILE_VERSION ] ) . map_err ( BundleCacheError :: Write ) ) ;
111+ try!( file. write_all ( & CACHE_FILE_STRING ) . map_err (
112+ BundleCacheError :: Write
113+ ) ) ;
114+ try!( file. write_all ( & [ CACHE_FILE_VERSION ] ) . map_err (
115+ BundleCacheError :: Write
116+ ) ) ;
105117 try!( msgpack:: encode_to_stream ( & list, & mut file) ) ;
106118 Ok ( ( ) )
107119 }
0 commit comments