@@ -11,6 +11,7 @@ use itertools::Itertools;
11
11
use petgraph:: graph:: NodeIndex ;
12
12
use petgraph:: visit:: EdgeRef ;
13
13
use rustc_hash:: { FxHashMap , FxHashSet } ;
14
+ use serde:: Serializer ;
14
15
use toml_edit:: { value, Array , ArrayOfTables , InlineTable , Item , Table , Value } ;
15
16
use url:: Url ;
16
17
@@ -617,7 +618,7 @@ impl Lock {
617
618
}
618
619
619
620
/// Returns the TOML representation of this lockfile.
620
- pub fn to_toml ( & self ) -> anyhow :: Result < String > {
621
+ pub fn to_toml ( & self ) -> Result < String , toml_edit :: ser :: Error > {
621
622
// We construct a TOML document manually instead of going through Serde to enable
622
623
// the use of inline tables.
623
624
let mut doc = toml_edit:: DocumentMut :: new ( ) ;
@@ -2085,7 +2086,7 @@ impl Package {
2085
2086
& self ,
2086
2087
requires_python : & RequiresPython ,
2087
2088
dist_count_by_name : & FxHashMap < PackageName , u64 > ,
2088
- ) -> anyhow :: Result < Table > {
2089
+ ) -> Result < Table , toml_edit :: ser :: Error > {
2089
2090
let mut table = Table :: new ( ) ;
2090
2091
2091
2092
self . id . to_toml ( None , & mut table) ;
@@ -2149,7 +2150,7 @@ impl Package {
2149
2150
self . wheels
2150
2151
. iter ( )
2151
2152
. map ( Wheel :: to_toml)
2152
- . collect :: < anyhow :: Result < Vec < _ > > > ( ) ?
2153
+ . collect :: < Result < Vec < _ > , _ > > ( ) ?
2153
2154
. into_iter ( ) ,
2154
2155
) ;
2155
2156
table. insert ( "wheels" , value ( wheels) ) ;
@@ -3224,7 +3225,7 @@ enum SourceDistWire {
3224
3225
3225
3226
impl SourceDist {
3226
3227
/// Returns the TOML representation of this source distribution.
3227
- fn to_toml ( & self ) -> anyhow :: Result < InlineTable > {
3228
+ fn to_toml ( & self ) -> Result < InlineTable , toml_edit :: ser :: Error > {
3228
3229
let mut table = InlineTable :: new ( ) ;
3229
3230
match & self {
3230
3231
SourceDist :: Metadata { .. } => { }
@@ -3239,7 +3240,10 @@ impl SourceDist {
3239
3240
table. insert ( "hash" , Value :: from ( hash. to_string ( ) ) ) ;
3240
3241
}
3241
3242
if let Some ( size) = self . size ( ) {
3242
- table. insert ( "size" , Value :: from ( i64:: try_from ( size) ?) ) ;
3243
+ table. insert (
3244
+ "size" ,
3245
+ toml_edit:: ser:: ValueSerializer :: new ( ) . serialize_u64 ( size) ?,
3246
+ ) ;
3243
3247
}
3244
3248
Ok ( table)
3245
3249
}
@@ -3612,7 +3616,7 @@ enum WheelWireSource {
3612
3616
3613
3617
impl Wheel {
3614
3618
/// Returns the TOML representation of this wheel.
3615
- fn to_toml ( & self ) -> anyhow :: Result < InlineTable > {
3619
+ fn to_toml ( & self ) -> Result < InlineTable , toml_edit :: ser :: Error > {
3616
3620
let mut table = InlineTable :: new ( ) ;
3617
3621
match & self . url {
3618
3622
WheelWireSource :: Url { url } => {
@@ -3629,7 +3633,10 @@ impl Wheel {
3629
3633
table. insert ( "hash" , Value :: from ( hash. to_string ( ) ) ) ;
3630
3634
}
3631
3635
if let Some ( size) = self . size {
3632
- table. insert ( "size" , Value :: from ( i64:: try_from ( size) ?) ) ;
3636
+ table. insert (
3637
+ "size" ,
3638
+ toml_edit:: ser:: ValueSerializer :: new ( ) . serialize_u64 ( size) ?,
3639
+ ) ;
3633
3640
}
3634
3641
Ok ( table)
3635
3642
}
0 commit comments