a simple update to handle weather http reqwests (#64)

This commit is contained in:
Mustafa Salih 2021-10-15 20:46:29 +03:00 committed by GitHub
parent ae533f1fe7
commit de2e6017f5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 7 deletions

View File

@ -1,6 +1,6 @@
[package] [package]
name = "rsblocks" name = "rsblocks"
version = "0.1.19" version = "0.1.20"
authors = ["mustafa salih <mustafasalih1991@gmail.com>"] authors = ["mustafa salih <mustafasalih1991@gmail.com>"]
edition = "2018" edition = "2018"
readme = "README.md" readme = "README.md"

View File

@ -3,13 +3,13 @@
[<img alt="crates" src="https://img.shields.io/crates/v/rsblocks?logo=rust&logoColor=a9b1d6&style=flat-square&color=fc8d62" height="20">](https://crates.io/crates/rsblocks) [<img alt="crates" src="https://img.shields.io/crates/v/rsblocks?logo=rust&logoColor=a9b1d6&style=flat-square&color=fc8d62" height="20">](https://crates.io/crates/rsblocks)
A multi threaded fast status bar for dwm window manager written in **Rust** 🦀 A status bar for dwm window manager written in **Rust** 🦀
<p> <p>
<img align="center" src="./screenshots/2.png"/> <img align="center" src="./screenshots/2.png"/>
</p><br/> </p><br/>
## Features ## Features
* Multi Threads * Async
* Battery Percentage * Battery Percentage
* Bitcoin Price * Bitcoin Price
* Brightness * Brightness

View File

@ -12,10 +12,16 @@ pub async fn get_weather() -> ThreadsData {
let url = format!("http://wttr.in/{}?format=\"{}", CONFIG.weather.city, format); let url = format!("http://wttr.in/{}?format=\"{}", CONFIG.weather.city, format);
let err_string = String::from("Error"); let err_string = String::from("Error");
let res = match minreq::get(url).send() { let res = match minreq::get(url).send() {
Ok(resp) => match resp.as_str() { Ok(resp) => {
if resp.status_code != 200 {
String::from("service error")
} else {
match resp.as_str() {
Ok(res_str) => res_str.trim_matches('"').to_string(), Ok(res_str) => res_str.trim_matches('"').to_string(),
Err(_) => err_string, Err(_) => err_string,
}, }
}
}
Err(_) => err_string, Err(_) => err_string,
}; };