1#![doc = include_str!(concat!(env!("OUT_DIR"), "/README-lib.md"))]
2#![forbid(unsafe_code)]
3#![deny(clippy::print_stdout, clippy::print_stderr)]
4#![cfg_attr(not(feature = "std"), no_std)]
5#![cfg_attr(docsrs, feature(doc_cfg))]
6extern crate alloc;
7
8mod constants;
9mod decimal;
10mod error;
11mod ops;
12pub mod str;
13
14mod arithmetic_impls;
16
17#[cfg(feature = "rust-fuzz")]
18mod fuzz;
19#[cfg(feature = "maths")]
20mod maths;
21#[cfg(all(feature = "db-diesel-mysql", not(target_arch = "wasm32")))]
22mod mysql;
23#[cfg(all(
24 any(
25 feature = "db-tokio-postgres",
26 feature = "db-postgres",
27 feature = "db-diesel-postgres",
28 ),
29 not(target_arch = "wasm32")
30))]
31mod postgres;
32#[cfg(feature = "proptest")]
33mod proptest;
34#[cfg(feature = "rand")]
35mod rand;
36#[cfg(feature = "rand-0_9")]
37mod rand_0_9;
38#[cfg(feature = "rocket-traits")]
39mod rocket;
40#[cfg(all(
41 feature = "serde",
42 not(any(
43 feature = "serde-with-str",
44 feature = "serde-with-float",
45 feature = "serde-with-arbitrary-precision"
46 ))
47))]
48mod serde;
49#[cfg(all(
51 feature = "serde",
52 any(
53 feature = "serde-with-str",
54 feature = "serde-with-float",
55 feature = "serde-with-arbitrary-precision"
56 )
57))]
58pub mod serde;
59#[cfg(all(target_arch = "wasm32", feature = "wasm"))]
60pub mod wasm;
61
62pub use decimal::{Decimal, RoundingStrategy};
63pub use error::Error;
64#[cfg(feature = "maths")]
65pub use maths::MathematicalOps;
66
67pub mod prelude {
69 #[cfg(feature = "macros")]
70 pub use super::dec;
71 #[cfg(feature = "maths")]
72 pub use crate::maths::MathematicalOps;
73 pub use crate::{Decimal, RoundingStrategy};
74 pub use core::str::FromStr;
75 pub use num_traits::{FromPrimitive, One, Signed, ToPrimitive, Zero};
76}
77
78#[cfg(feature = "macros")]
79pub use rust_decimal_macros::dec;
80
81#[cfg(all(feature = "diesel", not(target_arch = "wasm32")))]
82extern crate diesel;
83
84pub type Result<T> = core::result::Result<T, Error>;
87
88