///function wrapper for running the request
function wrapper for running the request
function wrapper for running the request
fn run_request(data: &mut RetrieverState, request_url: &String) {
    let request_response = reqwest::blocking::get(request_url.clone());
    match request_response {
        Ok(response) => {
            log_feedback(data, String::from("--Response returned successfully!\n"));
            log_feedback(data, String::from("Checking response content type..."));
            let headers = response.headers();
            let content_type = headers.get("content-type");
            if let Some(content) = content_type {
                let image_type = is_image_type(content.clone());
                match image_type {
                    ImageType::Other => log_feedback(
                        data,
                        String::from(
                            "Invalid or Unsupported HTTP Content Type: Could not process request\n",
                        ),
                    ),
                    _ => {
                        log_feedback(data, String::from("--Content type is supported!\n"));
                        let download_result =
                            run_image_download(data, image_type, response, request_url);
                        match download_result {
                            Ok(_x) => log_feedback(data, String::from("--Download Complete!\n")),
                            Err(err) => log_feedback(
                                data,
                                format!("Download aborted! An error occurred: {}\n", err),
                            ),
                        }
                    }
                }
            } else {
                log_feedback(
                    data,
                    String::from(
                        "Error: response header contained no content type. Could not download.\n",
                    ),
                )
            };
        }
        Err(err) => {
            //This should be any error result from the term.
            //So we just have to log the error in our feedback.
            log_feedback(
                data,
                format!("Http request failed! Returned an error: {}\n", err),
            )
        }
    }
}
fn run_request ( data : & mut RetrieverState , request_url : & String ) { let request_response = reqwest :: blocking :: get ( request_url . clone ( ) ) ; match request_response { Ok ( response ) => { log_feedback ( data , String :: from ( " \n " ) ) ; log_feedback ( data , String :: from ( " " ) ) ; let headers = response . headers ( ) ; let content_type = headers . get ( " " ) ; if let Some ( content ) = content_type { let image_type = is_image_type ( content . clone ( ) ) ; match image_type { ImageType :: Other => log_feedback ( data , String :: from ( " \n " , ) , ) , _ => { log_feedback ( data , String :: from ( " \n " ) ) ; let download_result = run_image_download ( data , image_type , response , request_url ) ; match download_result { Ok ( _x ) => log_feedback ( data , String :: from ( " \n " ) ) , Err ( err ) => log_feedback ( data , format ! ( " \n " err ) , ) , } } } } else { log_feedback ( data , String :: from ( " \n " , ) , ) } ; } Err ( err ) => { //This should be any error result from the term. //So we just have to log the error in our feedback. log_feedback ( data , format ! ( " \n " err ) , ) } } }
function wrapper for running the request
function wrapper for running the request
data
&mut RetrieverState
request_url
&String