Function openweathermap::blocking::weather[][src]

pub fn weather(
    location: &str,
    units: &str,
    lang: &str,
    api_key: &str
) -> Result<CurrentWeather, String>
Expand description

Fetches a weather update once and stops the thread immediately after success then returns the update.

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
    • coordinates given by comma separated latitude and longitude (e.g. "52.5244,13.4105"). |
  • 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 called CurrentWeather (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