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)]
 | 
			
		||||
pub struct WeatherResponse {
 | 
			
		||||
    pub cod: Option<u16>,        // Http code
 | 
			
		||||
    pub message: Option<String>, // Http error message
 | 
			
		||||
    #[serde(default)]
 | 
			
		||||
    pub coord: Option<Coord>,
 | 
			
		||||
    #[serde(default)]
 | 
			
		||||
    pub weather: Vec<Weather>,
 | 
			
		||||
    #[serde(default)]
 | 
			
		||||
    pub base: Option<String>,
 | 
			
		||||
    #[serde(default)]
 | 
			
		||||
    pub main: Option<Main>,
 | 
			
		||||
    #[serde(default)]
 | 
			
		||||
    pub visibility: Option<u32>,
 | 
			
		||||
    #[serde(with = "chrono::serde::ts_seconds_option")]
 | 
			
		||||
    pub dt: Option<DateTime<Utc>>,
 | 
			
		||||
    #[serde(default)]
 | 
			
		||||
    pub sys: Option<Sys>,
 | 
			
		||||
    #[serde(default)]
 | 
			
		||||
    pub timezone: Option<i32>,
 | 
			
		||||
    #[serde(default)]
 | 
			
		||||
    pub id: Option<u64>,
 | 
			
		||||
    #[serde(default)]
 | 
			
		||||
    pub name: Option<String>,
 | 
			
		||||
    #[serde(default)]
 | 
			
		||||
    pub wind: Option<Wind>,
 | 
			
		||||
    #[serde(default)]
 | 
			
		||||
    pub clouds: Option<Clouds>,
 | 
			
		||||
    #[serde(default)]
 | 
			
		||||
    pub rain: Option<Precipitation>, // "rain": { "1h": f32 } or "3h": f32
 | 
			
		||||
    pub rain: Option<Precipitation>,
 | 
			
		||||
    #[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 {
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user