@@ -571,6 +571,7 @@ pub struct Package {
571571 local : bool ,
572572 alternative : bool ,
573573 invalid_index_line : bool ,
574+ index_line : Option < String > ,
574575 edition : Option < String > ,
575576 resolver : Option < String > ,
576577 proc_macro : bool ,
@@ -1252,6 +1253,7 @@ impl Package {
12521253 local : false ,
12531254 alternative : false ,
12541255 invalid_index_line : false ,
1256+ index_line : None ,
12551257 edition : None ,
12561258 resolver : None ,
12571259 proc_macro : false ,
@@ -1427,6 +1429,14 @@ impl Package {
14271429 self
14281430 }
14291431
1432+ /// Override the auto-generated index line
1433+ ///
1434+ /// This can give more control over error cases than [`Package::invalid_index_line`]
1435+ pub fn index_line ( & mut self , line : & str ) -> & mut Package {
1436+ self . index_line = Some ( line. to_owned ( ) ) ;
1437+ self
1438+ }
1439+
14301440 pub fn links ( & mut self , links : & str ) -> & mut Package {
14311441 self . links = Some ( links. to_string ( ) ) ;
14321442 self
@@ -1496,22 +1506,26 @@ impl Package {
14961506 let c = t ! ( fs:: read( & self . archive_dst( ) ) ) ;
14971507 cksum ( & c)
14981508 } ;
1499- let name = if self . invalid_index_line {
1500- serde_json :: json! ( 1 )
1509+ let line = if let Some ( line ) = self . index_line . clone ( ) {
1510+ line
15011511 } else {
1502- serde_json:: json!( self . name)
1512+ let name = if self . invalid_index_line {
1513+ serde_json:: json!( 1 )
1514+ } else {
1515+ serde_json:: json!( self . name)
1516+ } ;
1517+ create_index_line (
1518+ name,
1519+ & self . vers ,
1520+ deps,
1521+ & cksum,
1522+ self . features . clone ( ) ,
1523+ self . yanked ,
1524+ self . links . clone ( ) ,
1525+ self . rust_version . as_deref ( ) ,
1526+ self . v ,
1527+ )
15031528 } ;
1504- let line = create_index_line (
1505- name,
1506- & self . vers ,
1507- deps,
1508- & cksum,
1509- self . features . clone ( ) ,
1510- self . yanked ,
1511- self . links . clone ( ) ,
1512- self . rust_version . as_deref ( ) ,
1513- self . v ,
1514- ) ;
15151529
15161530 let registry_path = if self . alternative {
15171531 alt_registry_path ( )
0 commit comments