@@ -422,6 +422,22 @@ impl RequestParams {
422
422
Self { request_input : Some ( value. into ( ) ) , ..self }
423
423
}
424
424
425
+ /// Sets the input as a URL from which provers can download the input data.
426
+ ///
427
+ /// This is a convenience method that creates a [RequestInput] with URL type.
428
+ ///
429
+ /// ```rust
430
+ /// # use boundless_market::request_builder::RequestParams;
431
+ /// # || -> anyhow::Result<()> {
432
+ /// RequestParams::new()
433
+ /// .with_input_url("https://fileserver.example/input.bin")?;
434
+ /// # Ok(())
435
+ /// # }().unwrap();
436
+ /// ```
437
+ pub fn with_input_url < T : TryInto < Url > > ( self , value : T ) -> Result < Self , T :: Error > {
438
+ Ok ( Self { request_input : Some ( RequestInput :: url ( value. try_into ( ) ?) ) , ..self } )
439
+ }
440
+
425
441
/// Gets the cycle count, returning an error if not set.
426
442
///
427
443
/// The cycle count is used to estimate proving costs.
@@ -934,6 +950,34 @@ mod tests {
934
950
RequestParams :: new ( ) . with_program_url ( url) . inspect_err ( |e| match * e { } ) . unwrap ( ) ;
935
951
}
936
952
953
+ #[ test]
954
+ fn request_params_with_input_url_infallible ( ) {
955
+ // When passing a parsed URL, with_input_url should be infallible.
956
+ // NOTE: The `match *e {}` incantation is a compile-time assert that this error cannot
957
+ // occur.
958
+ let url = Url :: parse ( "https://fileserver.example/input.bin" ) . unwrap ( ) ;
959
+ RequestParams :: new ( ) . with_input_url ( url) . inspect_err ( |e| match * e { } ) . unwrap ( ) ;
960
+ }
961
+
962
+ #[ test]
963
+ fn test_with_input_url ( ) {
964
+ // Test with string URL
965
+ let params =
966
+ RequestParams :: new ( ) . with_input_url ( "https://fileserver.example/input.bin" ) . unwrap ( ) ;
967
+
968
+ let input = params. request_input . unwrap ( ) ;
969
+ assert_eq ! ( input. inputType, RequestInputType :: Url ) ;
970
+ assert_eq ! ( input. data. as_ref( ) , "https://fileserver.example/input.bin" . as_bytes( ) ) ;
971
+
972
+ // Test with parsed URL
973
+ let url = Url :: parse ( "https://fileserver.example/input2.bin" ) . unwrap ( ) ;
974
+ let params = RequestParams :: new ( ) . with_input_url ( url) . unwrap ( ) ;
975
+
976
+ let input = params. request_input . unwrap ( ) ;
977
+ assert_eq ! ( input. inputType, RequestInputType :: Url ) ;
978
+ assert_eq ! ( input. data. as_ref( ) , "https://fileserver.example/input2.bin" . as_bytes( ) ) ;
979
+ }
980
+
937
981
#[ allow( dead_code) ]
938
982
trait AssertSend : Send { }
939
983
0 commit comments