Skip to main content

weatherapi_rs/files/
weather.rs

1use serde::{Deserialize, Serialize};
2
3#[derive(Serialize, Deserialize, Debug)]
4pub struct Location {
5    name: String,
6    region: String,
7    country: String,
8    lat: f32,
9    lon: f32,
10    tz_id: String,
11    localtime_epoch: i32,
12    localtime: String,
13}
14
15#[derive(Serialize, Deserialize, Debug)]
16pub struct Current {
17    last_updated_epoch: i32,
18    last_updated: String,
19    pub temp_c: f32,
20    temp_f: f32,
21    pub is_day: i32,
22    pub condition: Condition,
23    wind_mph: f32,
24    wind_kph: f32,
25    wind_degree: i32,
26    wind_dir: String,
27    pressure_mb: f32,
28    pressure_in: f32,
29    precip_mm: f32,
30    precip_in: f32,
31    humidity: i32,
32    cloud: i32,
33    feelslike_c: f32,
34    feelslike_f: f32,
35    vis_km: f32,
36    vis_miles: f32,
37    uv: f32,
38    gust_mph: f32,
39    gust_kph: f32,
40    pub air_quality: Option<AirQuality>,
41}
42
43#[derive(Serialize, Deserialize, Debug)]
44pub struct Condition {
45    pub text: String,
46    pub icon: String,
47    pub code: i32,
48}
49
50#[derive(Serialize, Deserialize, Debug)]
51pub struct AirQuality {
52    co: f32,
53    no2: f32,
54    o3: f32,
55    so2: f32,
56    pm2_5: f32,
57    pm10: f32,
58    #[serde(rename = "us-epa-index")]
59    pub us_epa_index: i32,
60    #[serde(rename = "gb-defra-index")]
61    gb_defra_index: i32,
62}
63
64#[derive(Serialize, Deserialize, Debug)]
65pub struct Weather {
66    pub location: Location,
67    pub current: Current,
68}