rink_core/
lib.rs

1// This Source Code Form is subject to the terms of the Mozilla Public
2// License, v. 2.0. If a copy of the MPL was not distributed with this
3// file, You can obtain one at https://mozilla.org/MPL/2.0/.
4
5/*! The primary interface of this library is meant to expose a very
6simple command-reply model for frontends, and to allow gradual
7addition of more advanced functionality. For now, only basic
8functionality exists.
9
10Using Rink as a library for uses other than simple unit conversion
11tools is not currently well supported, and if you wish to do so,
12please make issues for any problems you have.
13
14There are currently a number of hardcoded `println!`s and `unwrap()`s
15because most of this code was written in a day without much thought
16towards making it into a library.
17
18To use the library, check how the CLI tool does it. To get additional
19features like currency and BTC you'll need to fetch those files
20yourself and add them into the Context.
21
22## Example
23
24```rust
25use rink_core::*;
26
27let mut ctx = simple_context().unwrap();
28println!("{}", one_line(&mut ctx, "kWh / year -> W").unwrap());
29```
30*/
31
32// False positives, or make code harder to understand.
33#![allow(clippy::cognitive_complexity)]
34#![allow(clippy::match_like_matches_macro)]
35#![allow(clippy::from_str_radix_10)]
36#![allow(clippy::option_as_ref_deref)]
37#![allow(clippy::needless_lifetimes)]
38
39pub mod ast;
40pub mod commands;
41pub mod loader;
42pub mod output;
43pub mod parsing;
44pub mod runtime;
45pub mod types;
46
47pub(crate) mod algorithms;
48mod helpers;
49
50pub use crate::loader::Context;
51pub use crate::runtime::Value;
52pub use helpers::{
53    eval, one_line, simple_context, version, CURRENCY_FILE, DATES_FILE, DEFAULT_FILE,
54};