@@ -10,8 +10,8 @@ use crate::protocol::info_hash::{ConversionError, InfoHash};
1010
1111pub  type  NumberOfBytes  = i64 ; 
1212
13- // Query param name  
14- const  INFO_HASH_SCRAPE_PARAM :  & str  = "info_hash" ; 
13+ // Query param names  
14+ const  INFO_HASH :  & str  = "info_hash" ; 
1515
1616#[ derive( Debug ,  PartialEq ) ]  
1717pub  struct  Scrape  { 
@@ -27,12 +27,6 @@ pub enum ParseScrapeQueryError {
2727        location :  & ' static  Location < ' static > , 
2828        param_name :  String , 
2929    } , 
30-     #[ error( "invalid param value {param_value} for {param_name} in {location}" ) ]  
31-     InvalidParam  { 
32-         param_name :  String , 
33-         param_value :  String , 
34-         location :  & ' static  Location < ' static > , 
35-     } , 
3630    #[ error( "invalid param value {param_value} for {param_name} in {source}" ) ]  
3731    InvalidInfoHashParam  { 
3832        param_name :  String , 
@@ -60,14 +54,14 @@ impl TryFrom<Query> for Scrape {
6054} 
6155
6256fn  extract_info_hashes ( query :  & Query )  -> Result < Vec < InfoHash > ,  ParseScrapeQueryError >  { 
63-     match  query. get_param_vec ( INFO_HASH_SCRAPE_PARAM )  { 
57+     match  query. get_param_vec ( INFO_HASH )  { 
6458        Some ( raw_params)  => { 
6559            let  mut  info_hashes = vec ! [ ] ; 
6660
6761            for  raw_param in  raw_params { 
6862                let  info_hash =
6963                    percent_decode_info_hash ( & raw_param) . map_err ( |err| ParseScrapeQueryError :: InvalidInfoHashParam  { 
70-                         param_name :  INFO_HASH_SCRAPE_PARAM . to_owned ( ) , 
64+                         param_name :  INFO_HASH . to_owned ( ) , 
7165                        param_value :  raw_param. clone ( ) , 
7266                        source :  Located ( err) . into ( ) , 
7367                    } ) ?; 
@@ -80,7 +74,7 @@ fn extract_info_hashes(query: &Query) -> Result<Vec<InfoHash>, ParseScrapeQueryE
8074        None  => { 
8175            return  Err ( ParseScrapeQueryError :: MissingParam  { 
8276                location :  Location :: caller ( ) , 
83-                 param_name :  INFO_HASH_SCRAPE_PARAM . to_owned ( ) , 
77+                 param_name :  INFO_HASH . to_owned ( ) , 
8478            } ) 
8579        } 
8680    } 
@@ -92,16 +86,12 @@ mod tests {
9286    mod  scrape_request { 
9387
9488        use  crate :: http:: axum_implementation:: query:: Query ; 
95-         use  crate :: http:: axum_implementation:: requests:: scrape:: { Scrape ,  INFO_HASH_SCRAPE_PARAM } ; 
89+         use  crate :: http:: axum_implementation:: requests:: scrape:: { Scrape ,  INFO_HASH } ; 
9690        use  crate :: protocol:: info_hash:: InfoHash ; 
9791
9892        #[ test]  
9993        fn  should_be_instantiated_from_the_url_query_with_only_one_infohash ( )  { 
100-             let  raw_query = Query :: from ( vec ! [ ( 
101-                 INFO_HASH_SCRAPE_PARAM , 
102-                 "%3B%24U%04%CF%5F%11%BB%DB%E1%20%1C%EAjk%F4Z%EE%1B%C0" , 
103-             ) ] ) 
104-             . to_string ( ) ; 
94+             let  raw_query = Query :: from ( vec ! [ ( INFO_HASH ,  "%3B%24U%04%CF%5F%11%BB%DB%E1%20%1C%EAjk%F4Z%EE%1B%C0" ) ] ) . to_string ( ) ; 
10595
10696            let  query = raw_query. parse :: < Query > ( ) . unwrap ( ) ; 
10797
@@ -118,7 +108,7 @@ mod tests {
118108        mod  when_it_is_instantiated_from_the_url_query_params { 
119109
120110            use  crate :: http:: axum_implementation:: query:: Query ; 
121-             use  crate :: http:: axum_implementation:: requests:: scrape:: { Scrape ,  INFO_HASH_SCRAPE_PARAM } ; 
111+             use  crate :: http:: axum_implementation:: requests:: scrape:: { Scrape ,  INFO_HASH } ; 
122112
123113            #[ test]  
124114            fn  it_should_fail_if_the_query_does_not_include_the_info_hash_param ( )  { 
@@ -129,7 +119,7 @@ mod tests {
129119
130120            #[ test]  
131121            fn  it_should_fail_if_the_info_hash_param_is_invalid ( )  { 
132-                 let  raw_query = Query :: from ( vec ! [ ( INFO_HASH_SCRAPE_PARAM ,  "INVALID_INFO_HASH_VALUE" ) ] ) . to_string ( ) ; 
122+                 let  raw_query = Query :: from ( vec ! [ ( INFO_HASH ,  "INVALID_INFO_HASH_VALUE" ) ] ) . to_string ( ) ; 
133123
134124                assert ! ( Scrape :: try_from( raw_query. parse:: <Query >( ) . unwrap( ) ) . is_err( ) ) ; 
135125            } 
0 commit comments