cashify 0.1.1

Lightweight currency conversion library.
Documentation
  • Coverage
  • 0%
    0 out of 2 items documented0 out of 1 items with examples
  • Size
  • Source code size: 8.33 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 1.07 MB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 10s Average build duration of successful builds.
  • all releases: 10s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • xxczaki/cashify-rs
    8 4 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • xxczaki

Cashify 💸

Lightweight currency conversion library.

Build Status Crates cashify at docs.rs

This Rust crate is a port of the Cashify npm package from the same author. API is not the same.

Documentation

Installation

Simply add the corresponding entry to your Cargo.toml dependency list:

[dependencies]
cashify = "0.1"

Usage

The following example uses Serde JSON as strongly typed data structures. Instead of manually specifying rates, you can obtain them from an API, like Exchange Rates API.

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.

  • convert Function
  • Constructor
  • Parsing

Related projects

License

MIT