Function openweathermap::init [−][src]
pub fn init(
location: &str,
units: &str,
lang: &str,
api_key: &str,
poll_mins: u64
) -> Receiver
Expand description
Spawns a thread which fetches the current weather from openweathermap.org periodically.
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 herepoll_mins
: Update interval:> 0
: duration of poll period in minutes (10
is recommended)= 0
: thread will terminate after the first successful update.
Return value
-
openweathermap::Receiver
: Handle this toopenweathermap::update()
to get the latest weather update.The return value is a
mpsc
channel receiver:pub type Receiver = std::sync::mpsc::Receiver<Result<openweathermap::CurrentWeather, String>>;