11use reqwest:: { Client , Request } ;
2- use reqwest:: { Method , Error } ;
2+ use reqwest:: Method ;
3+ use reqwest:: Error as ReqwestError ;
34use reqwest:: header:: HeaderValue ;
45use url:: { Origin , Url } ;
56use reqwest:: header:: USER_AGENT ;
67use crate :: http:: { RobotsTxtClient , DEFAULT_USER_AGENT } ;
78use crate :: parser:: { ParseResult , parse_fetched_robots_txt} ;
89use crate :: model:: FetchedRobotsTxt ;
9- use crate :: model:: { RobotparserError , ErrorKind } ;
10+ use crate :: model:: { Error , ErrorKind } ;
1011use std:: pin:: Pin ;
1112use futures:: task:: { Context , Poll } ;
1213use futures:: Future ;
1314use futures:: future:: TryFutureExt ;
1415use futures:: future:: ok as future_ok;
1516
16- type FetchFuture = Box < dyn Future < Output =Result < ( ResponseInfo , String ) , Error > > > ;
17+ type FetchFuture = Box < dyn Future < Output =Result < ( ResponseInfo , String ) , ReqwestError > > > ;
1718
1819impl RobotsTxtClient for Client {
19- type Result = Result < RobotsTxtResponse , RobotparserError > ;
20+ type Result = Result < RobotsTxtResponse , Error > ;
2021 fn fetch_robots_txt ( & self , origin : Origin ) -> Self :: Result {
2122 let url = format ! ( "{}/robots.txt" , origin. unicode_serialization( ) ) ;
22- let url = Url :: parse ( & url) . map_err ( |err| RobotparserError { kind : ErrorKind :: Url ( err) } ) ?;
23+ let url = Url :: parse ( & url) . map_err ( |err| Error { kind : ErrorKind :: Url ( err) } ) ?;
2324 let mut request = Request :: new ( Method :: GET , url) ;
2425 let _ = request. headers_mut ( ) . insert ( USER_AGENT , HeaderValue :: from_static ( DEFAULT_USER_AGENT ) ) ;
2526 let response = self
@@ -30,7 +31,7 @@ impl RobotsTxtClient for Client {
3031 return future_ok ( ( response_info, response_text) ) ;
3132 } ) ;
3233 } ) ;
33- let response: Pin < Box < dyn Future < Output =Result < ( ResponseInfo , String ) , Error > > > > = Box :: pin ( response) ;
34+ let response: Pin < Box < dyn Future < Output =Result < ( ResponseInfo , String ) , ReqwestError > > > > = Box :: pin ( response) ;
3435 Ok ( RobotsTxtResponse {
3536 origin,
3637 response,
@@ -56,7 +57,7 @@ impl RobotsTxtResponse {
5657}
5758
5859impl Future for RobotsTxtResponse {
59- type Output = Result < ParseResult < FetchedRobotsTxt > , Error > ;
60+ type Output = Result < ParseResult < FetchedRobotsTxt > , ReqwestError > ;
6061
6162 fn poll ( self : Pin < & mut Self > , cx : & mut Context ) -> Poll < Self :: Output > {
6263 let self_mut = self . get_mut ( ) ;
0 commit comments