@@ -63,10 +63,8 @@ pub struct Component {
6363
6464impl Manifest {
6565 pub fn parse ( data : & str ) -> Result < Self > {
66- let mut parser = toml:: Parser :: new ( data) ;
67- let value = try!( parser. parse ( ) . ok_or_else ( move || ErrorKind :: Parsing ( parser. errors ) ) ) ;
68-
69- let manifest = try!( Self :: from_toml ( value, "" ) ) ;
66+ let value = toml:: from_str ( data) . map_err ( ErrorKind :: Parsing ) ?;
67+ let manifest = Self :: from_toml ( value, "" ) ?;
7068 try!( manifest. validate ( ) ) ;
7169
7270 Ok ( manifest)
@@ -75,7 +73,7 @@ impl Manifest {
7573 toml:: Value :: Table ( self . to_toml ( ) ) . to_string ( )
7674 }
7775
78- pub fn from_toml ( mut table : toml:: Table , path : & str ) -> Result < Self > {
76+ pub fn from_toml ( mut table : toml:: value :: Table , path : & str ) -> Result < Self > {
7977 let version = try!( get_string ( & mut table, "manifest-version" , path) ) ;
8078 if !SUPPORTED_MANIFEST_VERSIONS . contains ( & & * version) {
8179 return Err ( ErrorKind :: UnsupportedVersion ( version) . into ( ) ) ;
@@ -87,8 +85,8 @@ impl Manifest {
8785 renames : try!( Self :: table_to_renames ( table, path) ) ,
8886 } )
8987 }
90- pub fn to_toml ( self ) -> toml:: Table {
91- let mut result = toml:: Table :: new ( ) ;
88+ pub fn to_toml ( self ) -> toml:: value :: Table {
89+ let mut result = toml:: value :: Table :: new ( ) ;
9290
9391 result. insert ( "date" . to_owned ( ) , toml:: Value :: String ( self . date ) ) ;
9492 result. insert ( "manifest-version" . to_owned ( ) ,
@@ -103,7 +101,7 @@ impl Manifest {
103101 result
104102 }
105103
106- fn table_to_packages ( table : & mut toml:: Table , path : & str ) -> Result < HashMap < String , Package > > {
104+ fn table_to_packages ( table : & mut toml:: value :: Table , path : & str ) -> Result < HashMap < String , Package > > {
107105 let mut result = HashMap :: new ( ) ;
108106 let pkg_table = try!( get_table ( table, "pkg" , path) ) ;
109107
@@ -115,15 +113,15 @@ impl Manifest {
115113
116114 Ok ( result)
117115 }
118- fn packages_to_table ( packages : HashMap < String , Package > ) -> toml:: Table {
119- let mut result = toml:: Table :: new ( ) ;
116+ fn packages_to_table ( packages : HashMap < String , Package > ) -> toml:: value :: Table {
117+ let mut result = toml:: value :: Table :: new ( ) ;
120118 for ( k, v) in packages {
121119 result. insert ( k, toml:: Value :: Table ( v. to_toml ( ) ) ) ;
122120 }
123121 result
124122 }
125123
126- fn table_to_renames ( mut table : toml:: Table , path : & str ) -> Result < HashMap < String , String > > {
124+ fn table_to_renames ( mut table : toml:: value :: Table , path : & str ) -> Result < HashMap < String , String > > {
127125 let mut result = HashMap :: new ( ) ;
128126 let rename_table = try!( get_table ( & mut table, "rename" , path) ) ;
129127
@@ -135,10 +133,10 @@ impl Manifest {
135133
136134 Ok ( result)
137135 }
138- fn renames_to_table ( renames : HashMap < String , String > ) -> toml:: Table {
139- let mut result = toml:: Table :: new ( ) ;
136+ fn renames_to_table ( renames : HashMap < String , String > ) -> toml:: value :: Table {
137+ let mut result = toml:: value :: Table :: new ( ) ;
140138 for ( from, to) in renames {
141- let mut table = toml:: Table :: new ( ) ;
139+ let mut table = toml:: value :: Table :: new ( ) ;
142140 table. insert ( "to" . to_owned ( ) , toml:: Value :: String ( to) ) ;
143141 result. insert ( from, toml:: Value :: Table ( table) ) ;
144142 }
@@ -190,14 +188,14 @@ impl Manifest {
190188}
191189
192190impl Package {
193- pub fn from_toml ( mut table : toml:: Table , path : & str ) -> Result < Self > {
191+ pub fn from_toml ( mut table : toml:: value :: Table , path : & str ) -> Result < Self > {
194192 Ok ( Package {
195193 version : try!( get_string ( & mut table, "version" , path) ) ,
196194 targets : try!( Self :: toml_to_targets ( table, path) ) ,
197195 } )
198196 }
199- pub fn to_toml ( self ) -> toml:: Table {
200- let mut result = toml:: Table :: new ( ) ;
197+ pub fn to_toml ( self ) -> toml:: value :: Table {
198+ let mut result = toml:: value :: Table :: new ( ) ;
201199
202200 result. insert ( "version" . to_owned ( ) , toml:: Value :: String ( self . version ) ) ;
203201
@@ -207,7 +205,7 @@ impl Package {
207205 result
208206 }
209207
210- fn toml_to_targets ( mut table : toml:: Table , path : & str ) -> Result < PackageTargets > {
208+ fn toml_to_targets ( mut table : toml:: value :: Table , path : & str ) -> Result < PackageTargets > {
211209 let mut target_table = try!( get_table ( & mut table, "target" , path) ) ;
212210
213211 if let Some ( toml:: Value :: Table ( t) ) = target_table. remove ( "*" ) {
@@ -222,8 +220,8 @@ impl Package {
222220 Ok ( PackageTargets :: Targeted ( result) )
223221 }
224222 }
225- fn targets_to_toml ( targets : PackageTargets ) -> toml:: Table {
226- let mut result = toml:: Table :: new ( ) ;
223+ fn targets_to_toml ( targets : PackageTargets ) -> toml:: value :: Table {
224+ let mut result = toml:: value :: Table :: new ( ) ;
227225 match targets {
228226 PackageTargets :: Wildcard ( tpkg) => {
229227 result. insert ( "*" . to_owned ( ) , toml:: Value :: Table ( tpkg. to_toml ( ) ) ) ;
@@ -268,7 +266,7 @@ impl PackageTargets {
268266}
269267
270268impl TargetedPackage {
271- pub fn from_toml ( mut table : toml:: Table , path : & str ) -> Result < Self > {
269+ pub fn from_toml ( mut table : toml:: value :: Table , path : & str ) -> Result < Self > {
272270 let components = try!( get_array ( & mut table, "components" , path) ) ;
273271 let extensions = try!( get_array ( & mut table, "extensions" , path) ) ;
274272
@@ -293,10 +291,10 @@ impl TargetedPackage {
293291 } )
294292 }
295293 }
296- pub fn to_toml ( self ) -> toml:: Table {
294+ pub fn to_toml ( self ) -> toml:: value :: Table {
297295 let extensions = Self :: components_to_toml ( self . extensions ) ;
298296 let components = Self :: components_to_toml ( self . components ) ;
299- let mut result = toml:: Table :: new ( ) ;
297+ let mut result = toml:: value :: Table :: new ( ) ;
300298 if !extensions. is_empty ( ) {
301299 result. insert ( "extensions" . to_owned ( ) , toml:: Value :: Array ( extensions) ) ;
302300 }
@@ -321,7 +319,7 @@ impl TargetedPackage {
321319 self . bins . is_some ( )
322320 }
323321
324- fn toml_to_components ( arr : toml:: Array , path : & str ) -> Result < Vec < Component > > {
322+ fn toml_to_components ( arr : toml:: value :: Array , path : & str ) -> Result < Vec < Component > > {
325323 let mut result = Vec :: new ( ) ;
326324
327325 for ( i, v) in arr. into_iter ( ) . enumerate ( ) {
@@ -333,8 +331,8 @@ impl TargetedPackage {
333331
334332 Ok ( result)
335333 }
336- fn components_to_toml ( components : Vec < Component > ) -> toml:: Array {
337- let mut result = toml:: Array :: new ( ) ;
334+ fn components_to_toml ( components : Vec < Component > ) -> toml:: value :: Array {
335+ let mut result = toml:: value :: Array :: new ( ) ;
338336 for v in components {
339337 result. push ( toml:: Value :: Table ( v. to_toml ( ) ) ) ;
340338 }
@@ -343,7 +341,7 @@ impl TargetedPackage {
343341}
344342
345343impl Component {
346- pub fn from_toml ( mut table : toml:: Table , path : & str ) -> Result < Self > {
344+ pub fn from_toml ( mut table : toml:: value :: Table , path : & str ) -> Result < Self > {
347345 Ok ( Component {
348346 pkg : try!( get_string ( & mut table, "pkg" , path) ) ,
349347 target : try!( get_string ( & mut table, "target" , path) . map ( |s| {
@@ -355,8 +353,8 @@ impl Component {
355353 } ) ) ,
356354 } )
357355 }
358- pub fn to_toml ( self ) -> toml:: Table {
359- let mut result = toml:: Table :: new ( ) ;
356+ pub fn to_toml ( self ) -> toml:: value :: Table {
357+ let mut result = toml:: value :: Table :: new ( ) ;
360358 result. insert ( "target" . to_owned ( ) , toml:: Value :: String (
361359 self . target . map ( |t| t. to_string ( ) ) . unwrap_or_else ( ||"*" . to_owned ( ) )
362360 ) ) ;
0 commit comments