Notes#
As for REST API enabling libraries, the one with the most readily available information was Rocket, and that was the main reason Rocket was chosen for this app. However, it requires the nightly verison of Rust and, currently, it has no capabilities for asynchronous functions to work as REST handlers, which is why the Client created in download.rs is blocking instead of asynchronous.
Ideas for improvement:
- Adding actual testing. Note: Some tests added here.
- Adding some permanence, so requests closer in time than 10 minutes use a local cache'd copy.
- Either keeping the parameters of the last cache'd call too, to manually convert temperature units if the user asks for a different one, or change queries to always get them in Kelvin and always do the manual calculations when presenting the info to the user.
- Defining our own Json Weather & Forecast structs in
utils.rsto allow for more complex parsing.
- Adding the alternative API calls available at OpenWeather.
- Check that parameters are correct & compatible (city name with the country code, for example), using the resources from OpenWeather.
- Reusing the Http Client across API calls.
- Read the OpenWeather API key from parameters instead of hving it hardcoded.
Consulted Documentation#
- Rust crash course, Learn Rust in Y minutes, some entries in the Rust Programming Tutorials list, and How to build a command line app in Rust.
- Official docs for
tokio,reqwest,rocketand the differentserdeutilities. - Part 1, part 2 and part 3 of "Demystifying Closures, Futures, and async-await in Rust"