1#![doc = include_str!("../README.md")]
2
3#[cfg(any(feature = "serde", test))]
4use serde::{Deserialize, Serialize};
5
6use std::collections::HashMap;
7
8use factorion_math as math;
9use rug::Integer;
10pub mod calculation_results;
11pub mod calculation_tasks;
12pub mod comment;
13pub(crate) mod format;
14pub mod locale;
15pub mod parse;
16
17#[cfg(feature = "influxdb")]
18pub mod influxdb;
19
20pub use calculation_results::Calculation;
22pub use calculation_tasks::CalculationJob;
24pub use comment::{Commands, Comment};
26pub use factorion_math::rug;
28pub use parse::parse;
30
31use crate::locale::Locale;
32
33pub mod recommended {
34 pub use crate::calculation_results::recommended::*;
35 pub use crate::calculation_tasks::recommended::*;
36 pub use crate::parse::recommended::*;
37 pub use factorion_math::recommended::FLOAT_PRECISION;
38}
39
40#[derive(Debug, Clone)]
41#[cfg_attr(any(feature = "serde", test), derive(Serialize, Deserialize))]
42pub struct Consts<'a> {
43 pub float_precision: u32,
44 pub upper_calculation_limit: Integer,
45 pub upper_approximation_limit: Integer,
46 pub upper_subfactorial_limit: Integer,
47 pub upper_termial_limit: Integer,
48 pub upper_termial_approximation_limit: u32,
49 pub integer_construction_limit: Integer,
50 pub number_decimals_scientific: usize,
51 pub locales: HashMap<String, Locale<'a>>,
52 pub default_locale: String,
53}
54impl Default for Consts<'_> {
55 fn default() -> Self {
56 Consts {
57 float_precision: math::recommended::FLOAT_PRECISION,
58 upper_calculation_limit: calculation_tasks::recommended::UPPER_CALCULATION_LIMIT(),
59 upper_approximation_limit: calculation_tasks::recommended::UPPER_APPROXIMATION_LIMIT(),
60 upper_subfactorial_limit: calculation_tasks::recommended::UPPER_SUBFACTORIAL_LIMIT(),
61 upper_termial_limit: calculation_tasks::recommended::UPPER_TERMIAL_LIMIT(),
62 upper_termial_approximation_limit:
63 calculation_tasks::recommended::UPPER_TERMIAL_APPROXIMATION_LIMIT,
64 integer_construction_limit: parse::recommended::INTEGER_CONSTRUCTION_LIMIT(),
65 number_decimals_scientific:
66 calculation_results::recommended::NUMBER_DECIMALS_SCIENTIFIC,
67 #[cfg(any(feature = "serde", test))]
68 locales: crate::locale::get_all()
69 .map(|(s, l)| (s.to_owned(), l))
70 .collect(),
71 #[cfg(not(any(feature = "serde", test)))]
72 locales: HashMap::new(),
73 default_locale: "en".to_owned(),
74 }
75 }
76}