Function openweathermap::weather [−][src]
pub async fn weather(
location: &str,
units: &str,
lang: &str,
api_key: &str
) -> Result<CurrentWeather, String>
Expand description
Fetch current weather update once and stop thread immediately after success. Returns the result in a future.
Parameters
location
: Can be a city name, a city ID or a geographical coordinate:- city name: may be followed by comma separated state code and/or country code (e.g.
"Berlin,DE"
). - city ID: which can be found at this where you will get link that includes the ID
- e.g.
"2950159"
for Berlin, Germany
- e.g.
- coordinates: given by comma separated latitude and longitude (e.g.
"52.5244,13.4105"
). |
- city name: may be followed by comma separated state code and/or country code (e.g.
units
: One of the following:"metric"
: meters, m/s, °C, etc."imperial"
: miles, mi/s, °F, etc."standard"
: meters, m/s, K, etc.
lang
: Language code:"en"
: for English"de"
: for German- see this list for all available language codes
api_key
: Your API key which you can get here
Return value
- ⇒
Ok(CurrentWeather)
: weather information in a nested struct calledCurrentWeather
(see also OpenWeatherMap documentation for details) - ⇒
Err(String)
: Error message about any occured http or json issue - e.g.401 Unauthorized
if your API key is invalid - some json parser error message if response from OpenWeatherMap could not be parsed