vle_units/lib.rs
1//! VLE Units of Measurement
2//!
3//! Two layers:
4//!
5//! 1. **Compile-time typed quantities** — use `uom::si::f64::*` directly
6//! (e.g. `ThermodynamicTemperature`, `Pressure`, `MolarEnergy`,
7//! `TemperatureInterval`). `uom` enforces dimensional safety at compile
8//! time at zero runtime cost; we no longer wrap its types in `Vle*`
9//! aliases.
10//!
11//! 2. **Runtime registry API** ([`registry`], [`parser`], [`toml_loader`]) —
12//! used at the FFI boundary to parse user-supplied unit strings like
13//! `"3.5 barg"` or `"25 degC"`. Extensible at runtime: define new units
14//! or whole derived dimensions without recompiling.
15//!
16//! See [`docs/en/units/dimensional-analysis.md`] for the full design rationale.
17
18pub mod parser;
19pub mod registry;
20pub mod toml_loader;
21
22pub use registry::{Dimension, DimensionVector, RegistryError, UnitDef, UnitRegistry};
23
24/// Standard atmospheric pressure in **kPa** (1 standard atm).
25///
26/// Provided as a convenience constant — it is **never** used as a hidden
27/// default anywhere in the engine. All gauge ↔ absolute conversions in the
28/// [`UnitRegistry`] read P_atm from a configurable field
29/// ([`UnitRegistry::atmospheric_pressure_kpa`]).
30pub const P_ATM_STANDARD_KPA: f64 = 101.325;
31
32/// The raw TOML text used by [`UnitRegistry::with_vle_defaults`].
33///
34/// Baked into the binary at compile time via `include_str!`. Exposed so the
35/// Python wrapper (and any other FFI consumer) can derive its own unit
36/// definitions from the same source of truth as the Rust engine, instead of
37/// duplicating scale/offset constants.
38pub fn default_units_toml() -> &'static str {
39 include_str!("data/defaults.toml")
40}