Update struct WeatherResponse
- Better handling of missing fields
This commit is contained in:
parent
b97de37698
commit
d8048daa51
@ -68,28 +68,38 @@ pub struct Sys {
|
|||||||
|
|
||||||
#[derive(Debug, Clone, Deserialize, Serialize, Default)]
|
#[derive(Debug, Clone, Deserialize, Serialize, Default)]
|
||||||
pub struct WeatherResponse {
|
pub struct WeatherResponse {
|
||||||
pub cod: Option<u16>, // Http code
|
#[serde(default)]
|
||||||
pub message: Option<String>, // Http error message
|
|
||||||
pub coord: Option<Coord>,
|
pub coord: Option<Coord>,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub weather: Vec<Weather>,
|
pub weather: Vec<Weather>,
|
||||||
|
#[serde(default)]
|
||||||
pub base: Option<String>,
|
pub base: Option<String>,
|
||||||
|
#[serde(default)]
|
||||||
pub main: Option<Main>,
|
pub main: Option<Main>,
|
||||||
|
#[serde(default)]
|
||||||
pub visibility: Option<u32>,
|
pub visibility: Option<u32>,
|
||||||
#[serde(with = "chrono::serde::ts_seconds_option")]
|
#[serde(with = "chrono::serde::ts_seconds_option")]
|
||||||
pub dt: Option<DateTime<Utc>>,
|
pub dt: Option<DateTime<Utc>>,
|
||||||
|
#[serde(default)]
|
||||||
pub sys: Option<Sys>,
|
pub sys: Option<Sys>,
|
||||||
|
#[serde(default)]
|
||||||
pub timezone: Option<i32>,
|
pub timezone: Option<i32>,
|
||||||
|
#[serde(default)]
|
||||||
pub id: Option<u64>,
|
pub id: Option<u64>,
|
||||||
|
#[serde(default)]
|
||||||
pub name: Option<String>,
|
pub name: Option<String>,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub wind: Option<Wind>,
|
pub wind: Option<Wind>,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub clouds: Option<Clouds>,
|
pub clouds: Option<Clouds>,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub rain: Option<Precipitation>, // "rain": { "1h": f32 } or "3h": f32
|
pub rain: Option<Precipitation>,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub snow: Option<Precipitation>, // "snow": { "1h": f32 } or "3h": f32
|
pub snow: Option<Precipitation>,
|
||||||
|
#[serde(default)]
|
||||||
|
pub cod: Option<u16>,
|
||||||
|
#[serde(default)]
|
||||||
|
pub message: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl WeatherResponse {
|
impl WeatherResponse {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user