From f2ef0f00b48c11f12dc49b9d1e0c27b589e78d87 Mon Sep 17 00:00:00 2001 From: Namilskyy Date: Tue, 25 Mar 2025 19:48:26 +0300 Subject: Developing API response pacrser --- src/parser.rs | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'src/parser.rs') 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, } -: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(, )`, `lon(, )`."); + println!("HINT: To get more info check https://openweathermap.org/api/one-call-3") + } } -#[tokio::main] async pub fn parse_wheather() -> Result<(), Error>{ } -- cgit v1.2.3