-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🧩 Refactor(Downloader): Remove blocked methods in
reqwest
and forma…
…tted `Cargo.toml`
- Loading branch information
1 parent
a9de442
commit 94bdca7
Showing
5 changed files
with
175 additions
and
92 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,20 @@ | ||
extern crate reqwest; | ||
|
||
pub async fn _fetch_string_async(url: String) -> String { | ||
let resp = reqwest::get(url); | ||
resp.await.unwrap().text().await.unwrap() | ||
} | ||
|
||
pub fn fetch_string(url: String, time_out_milliseconds: i32) -> Option<String> { | ||
let response = reqwest::blocking::Client::builder() | ||
.timeout(std::time::Duration::from_millis(time_out_milliseconds as u64)) | ||
.build() | ||
.unwrap() | ||
.get(url) | ||
.send(); | ||
pub fn fetch_string(url: String) -> Option<String> { | ||
tokio::runtime::Builder::new_multi_thread().enable_all().build().unwrap().block_on(async { | ||
let response = reqwest::get(url).await; | ||
|
||
if response.is_err() { | ||
None | ||
} else { | ||
Some(response.unwrap().text().unwrap()) | ||
} | ||
if response.is_err() { | ||
None | ||
} else { | ||
Some(response.unwrap().text().await.unwrap()) | ||
} | ||
}) | ||
} | ||
|
||
pub fn fetch_binary(_url: String) -> Vec<u8> { | ||
let response = reqwest::blocking::get(_url).unwrap(); | ||
response.bytes().unwrap().to_vec() | ||
pub fn fetch_binary(url: String) -> Vec<u8> { | ||
tokio::runtime::Builder::new_multi_thread().enable_all().build().unwrap().block_on(async { | ||
let response = reqwest::get(url).await; | ||
response.unwrap().bytes().await.unwrap().to_vec() | ||
}) | ||
} |
Oops, something went wrong.