summaryrefslogtreecommitdiff
path: root/src/shared.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/shared.rs')
-rw-r--r--src/shared.rs128
1 files changed, 28 insertions, 100 deletions
diff --git a/src/shared.rs b/src/shared.rs
index 1afee09..75a4d1c 100644
--- a/src/shared.rs
+++ b/src/shared.rs
@@ -1,115 +1,43 @@
+use serde::{Serialize, Deserialize};
//API answer struct`s
+
#[derive(Debug, Serialize, Deserialize)]
pub struct WeatherData {
- pub lat: f64,
- pub lon: f64,
- pub timezone: String,
- pub timezone_offset: i32,
+ pub latitude: f64,
+ pub longitude: f64,
+ pub generationtime_ms: Option<f64>,
+ pub utc_offset_seconds: Option<i32>,
+ pub timezone: Option<String>,
+ pub timezone_abbreviation: Option<String>,
+ pub elevation: Option<f64>,
+ pub current_units: Option<CurrentUnits>,
pub current: Current,
- pub minutely: Option<Vec<Minutely>>,
- pub hourly: Option<Vec<Hourly>>,
- pub daily: Option<Vec<Daily>>,
- pub alerts: Option<Vec<Alert>>,
+ pub hourly_units: Option<HourlyUnits>,
+ pub hourly: Hourly,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct Current {
- pub dt: u64,
- pub sunrise: u64,
- pub sunset: u64,
- pub temp: f32,
- pub feels_like: f32,
- pub pressure: u32,
- pub humidity: u32,
- pub dew_point: f32,
- pub uvi: f32,
- pub clouds: u32,
- pub visibility: u32,
- pub wind_speed: f32,
- pub wind_deg: u32,
- pub wind_gust: f32,
- pub weather: Vec<Weather>,
-}
-
-#[derive(Debug, Serialize, Deserialize)]
-pub struct Weather {
- pub id: u32,
- pub main: String,
- pub description: String,
- pub icon: String,
+ pub time: String,
+ pub temperature_2m: f32,
+ pub wind_speed_10m: f32,
}
-
#[derive(Debug, Serialize, Deserialize)]
-pub struct Minutely {
- pub dt: u64,
- pub precipitation: f32,
+pub struct CurrentUnits {
+ pub time: Option<String>,
+ pub temperature_2m: Option<String>,
+ pub wind_speed_10m: Option<String>,
}
-
#[derive(Debug, Serialize, Deserialize)]
pub struct Hourly {
- pub dt: u64,
- pub temp: f32,
- pub feels_like: f32,
- pub pressure: u32,
- pub humidity: u32,
- pub dew_point: f32,
- pub uvi: f32,
- pub clouds: u32,
- pub visibility: u32,
- pub wind_speed: f32,
- pub wind_deg: u32,
- pub wind_gust: f32,
- pub weather: Vec<Weather>,
- pub pop: f32,
+ pub time: Vec<String>,
+ pub temperature_2m: Vec<f32>,
+ pub relative_humidity_2m: Vec<u32>,
+ pub wind_speed_10m: Vec<f32>,
}
-
#[derive(Debug, Serialize, Deserialize)]
-pub struct Daily {
- pub dt: u64,
- pub sunrise: u64,
- pub sunset: u64,
- pub moonrise: u64,
- pub moonset: u64,
- pub moon_phase: f32,
- pub summary: String,
- pub temp: Temp,
- pub feels_like: FeelsLike,
- pub pressure: u32,
- pub humidity: u32,
- pub dew_point: f32,
- pub wind_speed: f32,
- pub wind_deg: u32,
- pub wind_gust: f32,
- pub weather: Vec<Weather>,
- pub clouds: u32,
- pub pop: f32,
- pub rain: Option<f32>,
- pub uvi: f32,
+pub struct HourlyUnits {
+ pub time: Option<String>,
+ pub temperature_2m: Option<String>,
+ pub relative_humidity_2m: Option<String>,
+ pub wind_speed_10m: Option<String>,
}
-
-#[derive(Debug, Serialize, Deserialize)]
-pub struct Temp {
- pub day: f32,
- pub min: f32,
- pub max: f32,
- pub night: f32,
- pub eve: f32,
- pub morn: f32,
-}
-
-#[derive(Debug, Serialize, Deserialize)]
-pub struct FeelsLike {
- pub day: f32,
- pub night: f32,
- pub eve: f32,
- pub morn: f32,
-}
-
-#[derive(Debug, Serialize, Deserialize)]
-pub struct Alert {
- pub sender_name: String,
- pub event: String,
- pub start: u64,
- pub end: u64,
- pub description: String,
- pub tags: Vec<String>,
-} \ No newline at end of file