This program allows users to convert Euros (EUR) to a desired currency using the exchange rate fetched from a currency API.
- Fetch currency data for EUR from an API.
- Convert a given amount in EUR to a target currency.
- Clear and user-friendly console-based interface.
- Ability to exit the program at any point by typing "exit".
- chrono: For date handling.
- serde: For serializing and deserializing the JSON data.
- serde_json: For parsing JSON results.
- reqwest: For making HTTP requests.
- std: Standard library for collections, I/O operations, and process control.
- CurrencyJsonDataset: Represents the JSON data structure from the currency API.
date
: Date of the currency data.eur
: Mapping of currency codes to their exchange rate against EUR.
- main(): The main function where the program execution starts.
- currency_json_parsing(data: &str): Parses the JSON string into a
CurrencyJsonDataset
struct. - pause(): Pauses the console until the user presses a key.
- exit_user(value_str: &str): Checks if the user input is "exit" and exits the program if true.
Run the program. You will be prompted to:
- Enter the amount in EUR you want to convert.
- Enter the code of the target currency (e.g., USD, GBP, etc.).
- The program will display the converted amount in the desired currency.
- You can continue converting or type "exit" at any input prompt to terminate the program.
- The currency data source is "https://cdn.jsdelivr.net/gh/fawazahmed0/currency-api@1/latest/currencies/eur.json".
- The program assumes that the API always provides valid and up-to-date currency data.
Feel free to submit pull requests for new features or bug fixes.
EUPL v1.2