/*! * 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>>, } #[derive(Deserialize, Debug)] pub struct GeoCode { pub SAME: Vec, pub UGC: Vec, } /** * 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, } #[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, 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, pub title: String, pub updated: String, } #[derive(Deserialize, Debug)] pub struct Features { pub id: String, pub r#type: String, pub geometry: Option, 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, pub references: Vec, pub sent: String, pub effective: String, pub onset: Option, pub expires: String, pub ends: Option, 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, pub description: String, pub instruction: Option, pub response: String, #[serde(skip)] pub parameters: Vec, } #[derive(Deserialize, Debug)] pub struct AlertReferences { #[serde(rename = "@id")] pub id: String, pub identifier: String, pub sender: String, pub sent: String, } } // End of module