1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
|
/*!
* Weather.gov JSON Definitions
*
* Various structs to deserialize api responses
*
* Matt Kohls
* GPL v3
* 2023
*/
pub mod weather_gov_json {
#![allow(non_snake_case)]
use serde::Deserialize;
/**
* Common Objects
**/
#[derive(Deserialize, Debug)]
pub struct Context {
#[serde(rename = "")]
pub link: String,
pub jsonld: JsonLD,
}
#[derive(Deserialize, Debug)]
pub struct JsonLD {
#[serde(rename = "@version")]
pub version: String,
pub wx: String,
#[serde(default)]
pub geo: String,
#[serde(default)]
pub unit: String,
#[serde(alias = "@vocab")]
pub vocab: String,
}
#[derive(Deserialize, Debug)]
pub struct Geometry {
pub r#type: String,
pub coordinates: Vec<Vec<Vec<f32>>>,
}
#[derive(Deserialize, Debug)]
pub struct GeoCode {
pub SAME: Vec<String>,
pub UGC: Vec<String>,
}
/**
* Forecast
* https://www.weather.gov/documentation/services-web-api#/default/gridpoint_forecast
**/
#[derive(Deserialize, Debug)]
pub struct Forecast {
#[serde(rename = "@context")]
pub context: Context,
pub r#type: String,
pub geometry: Geometry,
pub properties: ForecastProperties,
}
#[derive(Deserialize, Debug)]
pub struct ForecastProperties {
pub updated: String,
pub units: String,
pub forecastGenerator: String,
pub generatedAt: String,
pub updateTime: String,
pub validTimes: String,
pub elevation: Elevation,
pub periods: Vec<Period>,
}
#[derive(Deserialize, Debug)]
pub struct Elevation {
pub unitCode: String,
pub value: f32,
}
#[derive(Deserialize, Debug)]
pub struct Period {
pub number: u32,
pub name: String,
pub startTime: String,
pub endTime: String,
pub isDaytime: bool,
pub temperature: i32,
pub temperatureUnit: String,
pub temperatureTrend: Option<String>,
pub windSpeed: String,
pub windDirection: String,
pub icon: String,
pub shortForecast: String,
pub detailedForecast: String,
}
/**
* Alerts
* https://www.weather.gov/documentation/services-web-api#/default/alerts_active
**/
#[derive(Deserialize, Debug)]
pub struct Alerts {
#[serde(rename = "@context", skip)]
pub context: String,
pub r#type: String,
pub features: Vec<Features>,
pub title: String,
pub updated: String,
}
#[derive(Deserialize, Debug)]
pub struct Features {
pub id: String,
pub r#type: String,
pub geometry: Option<Geometry>,
pub properties: AlertProperties,
}
#[derive(Deserialize, Debug)]
pub struct AlertProperties {
#[serde(rename = "@id")]
pub aid: String,
#[serde(rename = "@type")]
pub r#type: String,
pub id: String,
pub areaDesc: String,
pub geocode: GeoCode,
pub affectedZones: Vec<String>,
pub references: Vec<AlertReferences>,
pub sent: String,
pub effective: String,
pub onset: Option<String>,
pub expires: String,
pub ends: Option<String>,
pub status: String,
pub messageType: String,
pub category: String,
pub severity: String,
pub certainty: String,
pub urgency: String,
pub event: String,
pub sender: String,
pub senderName: String,
pub headline: Option<String>,
pub description: String,
pub instruction: Option<String>,
pub response: String,
#[serde(skip)]
pub parameters: Vec<String>,
}
#[derive(Deserialize, Debug)]
pub struct AlertReferences {
#[serde(rename = "@id")]
pub id: String,
pub identifier: String,
pub sender: String,
pub sent: String,
}
} // End of module
|