qtty
The user-facing crate that re-exports the qtty-core type system plus a curated set of astronomy-friendly units.
Highlights
- Strongly typed quantities backed by
Quantity<U>to prevent mixing incompatible dimensions. - Conversion is explicit and type-checked via
to::<TargetUnit>()with zero runtime overhead. - Includes handy derived aliases (
velocity,frequency, …) and astronomy staples (AU, light-year, solar mass/luminosity). - Works in
no_stdenvironments (useslibm) and has optionalserdesupport.
Included units
Every unit module from qtty-core is re-exported at the crate root for convenience:
- Angular (
Degrees,Radian, arcseconds, wrapping helpers) - Time (
Seconds,Minutes,Days, sidereal/astronomical variations) - Length (
Meters,Kilometers,AstronomicalUnit,LightYear, …) - Mass (
Kilograms,SolarMass) - Power (
Watts,SolarLuminosity) - Velocity and frequency (
Per<Length, Time>,Per<Angular, Time>aliases) unitlesshelpers for scalar quantities
Install
[]
= "0.1.0"
Disable default features for no_std:
[]
= { = "0.1.0", = false }
Quick start
use ;
let a = new;
let r = a.;
assert!;
use ;
use Velocity;
let d = new;
let t = new;
let v: = d / t;
assert!;
Feature flags
std(default): enablesstdsupport inqtty-core.serde: serializes/deserializesQuantity<U>as baref64values (unit is encoded by the type).pyo3: enables PyO3 conversions soQuantity<U>types convert to/from Pythonfloatand can be used directly as#[pyclass]fields (requires building with--features pyo3forqtty-core).
Related crates
qtty-core: the minimal zero-cost type system used underneath this facade.qtty-ffi: exposes the same quantities and conversions over a stable C ABI.
License
AGPL-3.0 (see ../LICENSE).