@@ -146,6 +146,8 @@ pub struct Package {
146146 invalid_json : bool ,
147147 proc_macro : bool ,
148148 links : Option < String > ,
149+ rust_version : Option < String > ,
150+ cargo_features : Vec < String > ,
149151}
150152
151153#[ derive( Clone ) ]
@@ -247,6 +249,8 @@ impl Package {
247249 invalid_json : false ,
248250 proc_macro : false ,
249251 links : None ,
252+ rust_version : None ,
253+ cargo_features : Vec :: new ( ) ,
250254 }
251255 }
252256
@@ -363,6 +367,12 @@ impl Package {
363367 self
364368 }
365369
370+ /// Specify a minimal Rust version.
371+ pub fn rust_version ( & mut self , rust_version : & str ) -> & mut Package {
372+ self . rust_version = Some ( rust_version. into ( ) ) ;
373+ self
374+ }
375+
366376 /// Causes the JSON line emitted in the index to be invalid, presumably
367377 /// causing Cargo to skip over this version.
368378 pub fn invalid_json ( & mut self , invalid : bool ) -> & mut Package {
@@ -375,6 +385,11 @@ impl Package {
375385 self
376386 }
377387
388+ pub fn cargo_feature ( & mut self , feature : & str ) -> & mut Package {
389+ self . cargo_features . push ( feature. to_owned ( ) ) ;
390+ self
391+ }
392+
378393 /// Creates the package and place it in the registry.
379394 ///
380395 /// This does not actually use Cargo's publishing system, but instead
@@ -502,15 +517,29 @@ impl Package {
502517 }
503518
504519 fn append_manifest < W : Write > ( & self , ar : & mut Builder < W > ) {
505- let mut manifest = format ! (
520+ let mut manifest = String :: new ( ) ;
521+
522+ if !self . cargo_features . is_empty ( ) {
523+ manifest. push_str ( & format ! (
524+ "cargo-features = {}\n \n " ,
525+ toml:: to_string( & self . cargo_features) . unwrap( )
526+ ) ) ;
527+ }
528+
529+ manifest. push_str ( & format ! (
506530 r#"
507531 [package]
508532 name = "{}"
509533 version = "{}"
510534 authors = []
511535 "# ,
512536 self . name, self . vers
513- ) ;
537+ ) ) ;
538+
539+ if let Some ( version) = & self . rust_version {
540+ manifest. push_str ( & format ! ( "rust-version = \" {}\" " , version) ) ;
541+ }
542+
514543 for dep in self . deps . iter ( ) {
515544 let target = match dep. target {
516545 None => String :: new ( ) ,
0 commit comments