summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNamilskyy <alive6863@gmail.com>2025-03-25 19:48:26 +0300
committerNamilskyy <alive6863@gmail.com>2025-03-25 19:48:26 +0300
commitf2ef0f00b48c11f12dc49b9d1e0c27b589e78d87 (patch)
tree1f8835e2b4b4e2582dfe82e3abc9fd2f1ace5d6e /src
parent4c812f56ba034a4ea4d79b83972826e623e3951d (diff)
Developing API response pacrser
Diffstat (limited to 'src')
-rw-r--r--src/configmanager.rs8
-rw-r--r--src/parser.rs22
2 files changed, 20 insertions, 10 deletions
diff --git a/src/configmanager.rs b/src/configmanager.rs
index e046aa2..c124419 100644
--- a/src/configmanager.rs
+++ b/src/configmanager.rs
@@ -13,12 +13,16 @@ pub struct Config {
cache: bool //Cacheing next Weather to dont use internet in next call
rain: String, //Path to rain image (png/jpg) or ASCII art int .txt
sunny: String, //Path to sunny image (png/jpg) or ASCII art int .txt
- snowy: String,
- //More info: OpenWeatherMap.org/api/one-call3
+ snowy: String,
}
+ //More info: OpenWeatherMap.org/api/one-call3
pub fn handle_config() -> Result<(), Box<dyn std::error::Error>>{
let Config_str = fs::read_to_string("~/.config/WeatherFetch/Config.toml");
let Config_parse: Config = toml::from_str(&data)?.except();
}
}
+
+pub fn gen_standart_conf() {
+
+}
diff --git a/src/parser.rs b/src/parser.rs
index 7d27194..62af697 100644
--- a/src/parser.rs
+++ b/src/parser.rs
@@ -1,14 +1,15 @@
-mod condfigmanager
-
use reqwest::{Error, Client, get};
use chrono::{DateTime, Utc, prelude::*};
use serde::{Serialize, Deserealize};
use std::net::{IpAddr, SocketAddr, UpdSocket};
-use tokio;
+mod configmanager;
+
+use configmanager::*;
static ErrBuff: String = reqwest::Error;
+//API answer struct`s
#[derive(Debug, Serialize, Deserialize)]
pub struct WeatherData {
pub lat: f64,
@@ -124,17 +125,22 @@ pub struct Alert {
pub description: String,
pub tags: Vec<String>,
}
-:qa
-:q
-async fn get_location(let ip: String) -> Reslut<(), >{
- let ip: String = reqwest::get("https://api.ipify.org").await?.text.await?;
+
+
+pub fn get_location(let ip: String) -> Reslut<(), >{
+ //Get the lat and lon for API call
+ if configmanager::Config.lat.is_empty() || configmanager::Config.lon.is_empty(){
+ println!("No coordinates in configuration file or conf not founded.");
+ println!("HINT: Try create ~/.config/WeatherFetch/Config.toml");
+ println!("HINT: And add `lat(<int>, <int>)`, `lon(<int>, <int>)`.");
+ println!("HINT: To get more info check https://openweathermap.org/api/one-call-3")
+ }
}
-#[tokio::main]
async pub fn parse_wheather() -> Result<(), Error>{
}