Git Product home page Git Product logo

cashify-rs's Introduction

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

cashify-rs's People

Contributors

xxczaki avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.