https://github.com/xxczaki/cashify-rs
Lightweight currency conversion library, written in Rust.
https://github.com/xxczaki/cashify-rs
cash cashify convert convert-currencies convert-currency-rates converter crate currency currency-exchange currency-rates exchange exchange-rates fixer money open-exchange-rates rates
Last synced: 6 months ago
JSON representation
Lightweight currency conversion library, written in Rust.
- Host: GitHub
- URL: https://github.com/xxczaki/cashify-rs
- Owner: xxczaki
- License: mit
- Created: 2020-06-02T08:18:00.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-06-10T12:01:47.000Z (over 5 years ago)
- Last Synced: 2025-03-25T09:04:07.102Z (7 months ago)
- Topics: cash, cashify, convert, convert-currencies, convert-currency-rates, converter, crate, currency, currency-exchange, currency-rates, exchange, exchange-rates, fixer, money, open-exchange-rates, rates
- Language: Rust
- Homepage: https://docs.rs/cashify
- Size: 8.79 KB
- Stars: 6
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: license.md
Awesome Lists containing this project
README
# Cashify 💸
> Lightweight currency conversion library.
[](https://travis-ci.org/xxczaki/cashify-rs)
[](https://crates.io/crates/cashify)
[](https://docs.rs/cashify)This Rust crate is a port of the [Cashify](https://github.com/xxczaki/cashify/) npm package from the same author. API is not the same.
## Documentation
- [Full API documentation](https://docs.rs/cashify)
## Installation
Simply add the corresponding entry to your `Cargo.toml` dependency list:
```toml
[dependencies]
cashify = "0.1"
```## Usage
The following example uses [Serde JSON](https://github.com/serde-rs/json) as strongly typed data structures. Instead of manually specifying rates, you can obtain them from an API, like [Exchange Rates API](https://exchangeratesapi.io/).
```rust
use std::collections::HashMap;
use serde::{Deserialize, Serialize};
use serde_json::Result;
use cashify::{convert};#[derive(Serialize, Deserialize)]
struct Rates<'a>{
base: &'a str,
rates: HashMap<&'a str, f64>
}fn main() -> Result<()> {
let data = r#"{
"base": "EUR",
"rates": {
"GBP": 0.92,
"EUR": 1
}
}"#;
let r: Rates = serde_json::from_str(data)?;println!("The result is: {}", convert(10.0, "EUR", "GBP", r.base, r.rates));
Ok(())
}
```## Roadmap
The goal is to try and implement as much features from the original Cashify as possible.
- [x] `convert` Function
- [ ] Constructor
- [ ] Parsing## Related projects
- [Cashify (TypeScript)](https://github.com/xxczaki/cashify/)
## License
MIT