From e50270f8f3b47b900edc73e79e92670c2bbb0f83 Mon Sep 17 00:00:00 2001 From: NerdyPepper Date: Mon, 16 Jul 2018 20:44:31 +0530 Subject: Use serde_json::Value instead or reqwest::Response --- src/content.rs | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) (limited to 'src') diff --git a/src/content.rs b/src/content.rs index f352f9f..13582f1 100644 --- a/src/content.rs +++ b/src/content.rs @@ -8,7 +8,6 @@ use cursive::utils::markup::StyledString; use cursive::Cursive; use cursive::views::Dialog; use serde_json::Value; -use reqwest::Response; use self::regex::Regex; pub fn query_url_gen(title: &str) -> String { @@ -42,11 +41,7 @@ pub fn search_url_gen(search: &str) -> String { url } -pub fn get_extract(mut res: Response) -> Result { - let v: Value = match serde_json::from_str(&res.text()?) { - Ok(x) => x, - Err(x) => panic!("Failed to parse json\nReceived error {}", x), - }; +pub fn get_extract(v: &Value) -> Result { let pageid = &v["query"]["pageids"][0]; let pageid_str = match pageid { Value::String(id) => id, @@ -120,11 +115,7 @@ pub fn get_search_results(search: &str) -> Result, reqwest::Error> { Ok(results) } -pub fn get_links(mut res: Response) -> Result, reqwest::Error> { - let v: Value = match serde_json::from_str(&res.text()?) { - Ok(x) => x, - Err(x) => panic!("Failed to parse json\nReceived error {}", x), - }; +pub fn get_links(v: &Value) -> Result, reqwest::Error> { let pageid = &v["query"]["pageids"][0]; let pageid_str = match pageid { Value::String(id) => id, -- cgit v1.2.3