summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAdam <56338480+adastx@users.noreply.github.com>2022-07-25 18:44:17 +0200
committerAdam <56338480+adastx@users.noreply.github.com>2022-07-25 18:44:17 +0200
commit5406651b29e3db786f31588e4fe91a8a40bf195f (patch)
treecbbafcbc9250870c482c68680fbc9bb4298d687a /src
parent510ceec33104f71591c03cfdbbba2a6911ec6ac4 (diff)
Minor refactor
Diffstat (limited to 'src')
-rw-r--r--src/main.rs40
1 files changed, 20 insertions, 20 deletions
diff --git a/src/main.rs b/src/main.rs
index 2bdb798..402b7c5 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -25,6 +25,26 @@ fn main() {
);
}
+fn setup() -> (String, String) {
+ let city_id = read_file("city_id");
+ let api_key = read_file("api_key");
+
+ let weather_url: String = format!(
+ "https://api.openweathermap.org/data/2.5/weather?id={}&appid={}&units=metric",
+ city_id, api_key
+ );
+ let forecast_url: String = format!(
+ "https://api.openweathermap.org/data/2.5/forecast?id={}&appid={}&units=metric&cnt=1",
+ city_id, api_key
+ );
+ (weather_url, forecast_url)
+}
+
+fn read_file(file_name: &str) -> String {
+ let path = Path::new(CONFIG_PATH).join(file_name);
+ fs::read_to_string(path.to_string_lossy().to_string()).unwrap()
+}
+
fn request_weather(
(weather_url, forecast_url): (String, String),
) -> Result<(String, String), reqwest::Error> {
@@ -89,23 +109,3 @@ fn get_trend_icon(t1: i32, t2: i32) -> char {
''
}
}
-
-fn setup() -> (String, String) {
- let city_id = read_file("city_id");
- let api_key = read_file("api_key");
-
- let current_url: String = format!(
- "https://api.openweathermap.org/data/2.5/weather?id={}&appid={}&units=metric",
- city_id, api_key
- );
- let forecast_url: String = format!(
- "https://api.openweathermap.org/data/2.5/forecast?id={}&appid={}&units=metric&cnt=1",
- city_id, api_key
- );
- (current_url, forecast_url)
-}
-
-fn read_file(file_name: &str) -> String {
- let path = Path::new(CONFIG_PATH).join(file_name);
- fs::read_to_string(path.to_string_lossy().to_string()).unwrap()
-}