Expand description
§space-units
Type-safe units of measure for aerospace quantities.
This crate provides 40 concrete newtypes for physical quantities
(Length, Mass, Velocity, Force, Voltage, Temperature, …)
where only physically meaningful arithmetic compiles, conversions are explicit,
and units are always part of the type.
§Quick Start
use space_units::prelude::*;
let distance = 384_400.km(); // Length
let time = 3.days(); // Time
let velocity = distance / time; // Length / Time → Velocity
let force = 1000.kg() * 9.81.mps2(); // Mass * Acceleration → Force§Key Features
- 82 typed arithmetic operations —
Length / Time → Velocity,Voltage * Current → Power, etc. NumericExtliteral extensions —384_400.km(),51.6.deg(),28.volts()- 34 typed constants —
constants::GM_EARTH,constants::C,constants::AU, etc. - Zero dependencies,
no_stdcompatible,const fnconstructors
Import prelude for the common case:
use space_units::prelude::*;Modules§
Structs§
- Absorbed
Dose - An absorbed radiation dose quantity, stored internally in grays (Gy).
- Acceleration
- An acceleration quantity, stored canonically in meters per second squared (m/s^2).
- Angle
- A plane angle, stored canonically in radians.
- Angular
Acceleration - An angular acceleration, stored canonically in rad/s².
- Angular
Momentum - An angular momentum, stored canonically in newton-metre-seconds (Nms).
- Angular
Velocity - An angular velocity (rate of rotation), stored canonically in rad/s.
- Area
- An area quantity, stored canonically in square meters (m²).
- Capacitance
- A capacitance quantity, stored internally in farads (F).
- Data
Rate - A data rate quantity, stored internally in bits per second (bps).
- Density
- A density quantity, stored canonically in kilograms per cubic meter (kg/m³).
- Display
With Unit - A display helper returned by
Quantity::display_as(Unit). - Dose
Equivalent - A dose equivalent quantity, stored internally in sieverts (Sv).
- Electric
Charge - An electric charge quantity, stored internally in coulombs (C).
- Electric
Current - An electric current quantity, stored internally in amperes (A).
- Energy
- An energy quantity, stored canonically in joules (J).
- Force
- A force quantity, stored canonically in Newtons (N).
- Frequency
- A frequency quantity, stored internally in hertz (Hz).
- Gravitational
Parameter - A gravitational parameter (mu = GM), stored canonically in m³/s².
- Heat
Flux - A heat flux quantity, stored canonically in watts per square meter (W/m²).
- Impulse
- An impulse quantity, stored canonically in Newton-seconds (N*s).
- Inductance
- An inductance quantity, stored internally in henrys (H).
- Length
- A length / distance quantity, stored canonically in meters (m).
- Magnetic
Flux - A magnetic flux quantity, stored internally in webers (Wb).
- Magnetic
Flux Density - A magnetic flux density quantity, stored internally in tesla (T).
- Mass
- A mass quantity, stored canonically in kilograms (kg).
- Mass
Flow Rate - A mass flow rate quantity, stored canonically in kilograms per second (kg/s).
- Moment
OfInertia - A moment of inertia (rotational inertia), stored canonically in kg*m².
- Momentum
- A momentum quantity, stored canonically in kg*m/s.
- Power
- A power quantity, stored canonically in watts (W).
- Pressure
- A pressure quantity, stored canonically in pascals (Pa).
- Resistance
- An electrical resistance quantity, stored internally in ohms (Ohm).
- Solid
Angle - A solid angle (two-dimensional angular span), stored canonically in steradians (sr).
- Specific
Angular Momentum - A specific angular momentum quantity, stored canonically in m²/s.
- Specific
Energy - A specific energy quantity, stored canonically in J/kg (= m²/s²).
- Specific
Impulse - A specific impulse quantity, stored canonically in seconds (s).
- Temperature
- A temperature quantity, stored canonically in kelvin (K).
- Time
- A time duration quantity, stored canonically in seconds (s).
- Torque
- A torque (moment of force), stored canonically in newton-metres (N*m).
- Velocity
- A velocity quantity, stored canonically in meters per second (m/s).
- Voltage
- A voltage (electric potential difference) quantity, stored internally in volts (V).
- Volume
- A volume quantity, stored canonically in cubic meters (m³).
Enums§
- Absorbed
Dose Unit - Display/conversion units for
AbsorbedDose. - Acceleration
Unit - Display / conversion units for
Acceleration. - Angle
Unit - Display and conversion units for
Angle. - Angular
Acceleration Unit - Display and conversion units for
AngularAcceleration. - Angular
Momentum Unit - Display and conversion units for
AngularMomentum. - Angular
Velocity Unit - Display and conversion units for
AngularVelocity. - Area
Unit - Display/conversion units for
Area. - Capacitance
Unit - Display/conversion units for
Capacitance. - Data
Rate Unit - Display/conversion units for
DataRate. - Density
Unit - Display/conversion units for
Density. - Dose
Equivalent Unit - Display/conversion units for
DoseEquivalent. - Electric
Charge Unit - Display/conversion units for
ElectricCharge. - Electric
Current Unit - Display/conversion units for
ElectricCurrent. - Energy
Unit - Display/conversion units for
Energy. - Force
Unit - Display / conversion units for
Force. - Frequency
Unit - Display/conversion units for
Frequency. - Gravitational
Parameter Unit - Display/conversion units for
GravitationalParameter. - Heat
Flux Unit - Display/conversion units for
HeatFlux. - Impulse
Unit - Display / conversion units for
Impulse. - Inductance
Unit - Display/conversion units for
Inductance. - Length
Unit - Display / conversion units for
Length. - Magnetic
Flux Density Unit - Display/conversion units for
MagneticFluxDensity. - Magnetic
Flux Unit - Display/conversion units for
MagneticFlux. - Mass
Flow Rate Unit - Display/conversion units for
MassFlowRate. - Mass
Unit - Display / conversion units for
Mass. - Moment
OfInertia Unit - Display and conversion units for
MomentOfInertia. - Power
Unit - Display/conversion units for
Power. - Pressure
Unit - Display/conversion units for
Pressure. - Resistance
Unit - Display/conversion units for
Resistance. - Solid
Angle Unit - Display and conversion units for
SolidAngle. - Specific
Angular Momentum Unit - Display/conversion units for
SpecificAngularMomentum. - Specific
Energy Unit - Display/conversion units for
SpecificEnergy. - Specific
Impulse Unit - Display/conversion units for
SpecificImpulse. - Temperature
Unit - Display/conversion units for
Temperature. - Time
Unit - Display / conversion units for
Time. - Torque
Unit - Display and conversion units for
Torque. - Velocity
Unit - Display / conversion units for
Velocity. - Voltage
Unit - Display/conversion units for
Voltage. - Volume
Unit - Display/conversion units for
Volume.
Traits§
- Numeric
Ext - Extension methods on numeric literals for constructing typed quantities.