pub struct Qty<const L: i8, const M: i8, const T: i8, const I: i8, const K: i8, const N: i8, const J: i8>(/* private fields */);Expand description
A quantity, with the seven SI base dimensions in its type.
The parameters are the exponents of metre, kilogram, second, ampere, kelvin,
mole and candela, in that order, so a velocity (m·s⁻¹) is Qty<1,0,-1,0,0,0,0>
— which is what Velocity names.
Addition, subtraction, negation, comparison and scaling by a plain f64 work
for every dimension. Multiplication and division between two quantities work
for the pairs declared in this module.
Implementations§
Source§impl<const L: i8, const M: i8, const T: i8, const I: i8, const K: i8, const N: i8, const J: i8> Qty<L, M, T, I, K, N, J>
impl<const L: i8, const M: i8, const T: i8, const I: i8, const K: i8, const N: i8, const J: i8> Qty<L, M, T, I, K, N, J>
Sourcepub const fn from_si(value: f64) -> Self
pub const fn from_si(value: f64) -> Self
Wrap a number already in SI base units. The escape hatch: use it when a dimension has no name here, and name it if you use it twice.
const, so a dimensioned constant can be written without a lazy static.
Sourcepub const fn dimension() -> [i8; 7]
pub const fn dimension() -> [i8; 7]
The seven exponents, for diagnostics and for a runtime dimension check at a boundary the type system does not cross (deserialisation, FFI).
Source§impl Qty<3, 1, -3, -2, 0, 0, 0>
impl Qty<3, 1, -3, -2, 0, 0, 0>
Sourcepub fn ohm_m(v: f64) -> Resistivity
pub fn ohm_m(v: f64) -> Resistivity
Ohm-metres. Copper is 1.724e-8 at 20 °C, aluminium 2.65e-8, and a resistor’s ceramic substrate is fourteen orders of magnitude up from either.
Sourcepub fn micro_ohm_cm(v: f64) -> Resistivity
pub fn micro_ohm_cm(v: f64) -> Resistivity
µΩ·cm, which is what a materials datasheet quotes: copper is 1.724.
Sourcepub fn conductivity(self) -> Conductivity
pub fn conductivity(self) -> Conductivity
The conductivity that is its reciprocal. Zero resistivity gives an infinite conductivity, which is the honest answer and not a panic.
Source§impl Qty<-3, -1, 3, 2, 0, 0, 0>
impl Qty<-3, -1, 3, 2, 0, 0, 0>
Sourcepub fn s_per_m(v: f64) -> Conductivity
pub fn s_per_m(v: f64) -> Conductivity
Siemens per metre.
Sourcepub fn resistivity(self) -> Resistivity
pub fn resistivity(self) -> Resistivity
The resistivity that is its reciprocal.
Source§impl Qty<-2, 0, 0, 1, 0, 0, 0>
impl Qty<-2, 0, 0, 1, 0, 0, 0>
Sourcepub fn a_per_m2(v: f64) -> CurrentDensity
pub fn a_per_m2(v: f64) -> CurrentDensity
Amperes per square metre.
Sourcepub fn a_per_mm2(v: f64) -> CurrentDensity
pub fn a_per_mm2(v: f64) -> CurrentDensity
A/mm², which is how a cable’s rating is quoted — 5 A/mm² is a normal continuous figure for insulated copper in air.
Source§impl Qty<2, 1, -3, -2, 0, 0, 0>
impl Qty<2, 1, -3, -2, 0, 0, 0>
Sourcepub fn ohm(v: f64) -> Resistance
pub fn ohm(v: f64) -> Resistance
Ohms.
Sourcepub fn milliohm(v: f64) -> Resistance
pub fn milliohm(v: f64) -> Resistance
Milliohms — the range a motor winding or a shunt actually lives in.
Source§impl Qty<1, 0, 0, 0, 0, 0, 0>
impl Qty<1, 0, 0, 0, 0, 0, 0>
Source§impl Qty<0, 0, 0, 0, 1, 0, 0>
impl Qty<0, 0, 0, 0, 1, 0, 0>
Sourcepub fn kelvin(v: f64) -> Temperature
pub fn kelvin(v: f64) -> Temperature
Kelvin, which is what is stored.
Sourcepub fn celsius(v: f64) -> Temperature
pub fn celsius(v: f64) -> Temperature
Celsius is an offset scale, not a scaled one, which is why it gets a named constructor rather than a factor: 20 °C is 293.15 K, and a temperature difference of 20 K is a different thing entirely.
Sourcepub fn in_celsius(self) -> f64
pub fn in_celsius(self) -> f64
As degrees Celsius. Subtracts the offset; see Temperature::celsius.
Source§impl Qty<0, 1, -3, 0, 0, 0, 0>
impl Qty<0, 1, -3, 0, 0, 0, 0>
Sourcepub fn w_per_m2(v: f64) -> Irradiance
pub fn w_per_m2(v: f64) -> Irradiance
Watts per square metre, which is what is stored.
Sourcepub fn mw_per_cm2(v: f64) -> Irradiance
pub fn mw_per_cm2(v: f64) -> Irradiance
How an illumination spec is usually written: mW/cm².
Source§impl Qty<1, 1, -3, 0, -1, 0, 0>
impl Qty<1, 1, -3, 0, -1, 0, 0>
Sourcepub fn w_per_m_k(v: f64) -> ThermalConductivity
pub fn w_per_m_k(v: f64) -> ThermalConductivity
W·m⁻¹·K⁻¹, the unit a materials table uses.
Source§impl Qty<2, 0, -2, 0, -1, 0, 0>
impl Qty<2, 0, -2, 0, -1, 0, 0>
Sourcepub fn j_per_kg_k(v: f64) -> SpecificHeat
pub fn j_per_kg_k(v: f64) -> SpecificHeat
J·kg⁻¹·K⁻¹, the unit a materials table uses.
Source§impl Qty<2, 0, -2, 0, 0, 0, 0>
impl Qty<2, 0, -2, 0, 0, 0, 0>
Sourcepub fn j_per_kg(v: f64) -> LatentHeat
pub fn j_per_kg(v: f64) -> LatentHeat
J·kg⁻¹.
Sourcepub fn kj_per_kg(v: f64) -> LatentHeat
pub fn kj_per_kg(v: f64) -> LatentHeat
kJ·kg⁻¹, which is the unit every table of latent heats is written in.
Source§impl Qty<2, 1, -2, 0, -1, 0, 0>
impl Qty<2, 1, -2, 0, -1, 0, 0>
Sourcepub fn j_per_k(v: f64) -> HeatCapacity
pub fn j_per_k(v: f64) -> HeatCapacity
Joules per kelvin. The companion to Conductance::w_per_k: their ratio is a time
constant, and the type system says so.
Trait Implementations§
Source§impl<const L: i8, const M: i8, const T: i8, const I: i8, const K: i8, const N: i8, const J: i8> Add for Qty<L, M, T, I, K, N, J>
impl<const L: i8, const M: i8, const T: i8, const I: i8, const K: i8, const N: i8, const J: i8> Add for Qty<L, M, T, I, K, N, J>
Source§impl<const L: i8, const M: i8, const T: i8, const I: i8, const K: i8, const N: i8, const J: i8> AddAssign for Qty<L, M, T, I, K, N, J>
impl<const L: i8, const M: i8, const T: i8, const I: i8, const K: i8, const N: i8, const J: i8> AddAssign for Qty<L, M, T, I, K, N, J>
Source§fn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
+= operation. Read moreSource§impl<const L: i8, const M: i8, const T: i8, const I: i8, const K: i8, const N: i8, const J: i8> Clone for Qty<L, M, T, I, K, N, J>
impl<const L: i8, const M: i8, const T: i8, const I: i8, const K: i8, const N: i8, const J: i8> Clone for Qty<L, M, T, I, K, N, J>
impl<const L: i8, const M: i8, const T: i8, const I: i8, const K: i8, const N: i8, const J: i8> Copy for Qty<L, M, T, I, K, N, J>
Source§impl<const L: i8, const M: i8, const T: i8, const I: i8, const K: i8, const N: i8, const J: i8> Debug for Qty<L, M, T, I, K, N, J>
impl<const L: i8, const M: i8, const T: i8, const I: i8, const K: i8, const N: i8, const J: i8> Debug for Qty<L, M, T, I, K, N, J>
Source§impl<const L: i8, const M: i8, const T: i8, const I: i8, const K: i8, const N: i8, const J: i8> Default for Qty<L, M, T, I, K, N, J>
impl<const L: i8, const M: i8, const T: i8, const I: i8, const K: i8, const N: i8, const J: i8> Default for Qty<L, M, T, I, K, N, J>
Source§impl<'de, const L: i8, const M: i8, const T: i8, const I: i8, const K: i8, const N: i8, const J: i8> Deserialize<'de> for Qty<L, M, T, I, K, N, J>
impl<'de, const L: i8, const M: i8, const T: i8, const I: i8, const K: i8, const N: i8, const J: i8> Deserialize<'de> for Qty<L, M, T, I, K, N, J>
Source§fn deserialize<D: Deserializer<'de>>(d: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(d: D) -> Result<Self, D::Error>
Source§impl<const L: i8, const M: i8, const T: i8, const I: i8, const K: i8, const N: i8, const J: i8> Display for Qty<L, M, T, I, K, N, J>
impl<const L: i8, const M: i8, const T: i8, const I: i8, const K: i8, const N: i8, const J: i8> Display for Qty<L, M, T, I, K, N, J>
Source§impl<const L: i8, const M: i8, const T: i8, const I: i8, const K: i8, const N: i8, const J: i8> Div for Qty<L, M, T, I, K, N, J>
Dividing two quantities of the same dimension gives a plain number — which
is the one product rule that needs no exponent arithmetic, and the one every
tolerance check uses.
impl<const L: i8, const M: i8, const T: i8, const I: i8, const K: i8, const N: i8, const J: i8> Div for Qty<L, M, T, I, K, N, J>
Dividing two quantities of the same dimension gives a plain number — which is the one product rule that needs no exponent arithmetic, and the one every tolerance check uses.
Source§impl Div<Qty<0, 0, 0, 0, 1, 0, 0>> for LatentHeat
impl Div<Qty<0, 0, 0, 0, 1, 0, 0>> for LatentHeat
Source§fn div(self, rhs: Temperature) -> SpecificHeat
fn div(self, rhs: Temperature) -> SpecificHeat
/ operation. Read moreSource§impl Div<Qty<0, 0, 0, 0, 1, 0, 0>> for Power
impl Div<Qty<0, 0, 0, 0, 1, 0, 0>> for Power
Source§fn div(self, rhs: Temperature) -> Conductance
fn div(self, rhs: Temperature) -> Conductance
/ operation. Read moreSource§impl Div<Qty<0, 0, 0, 0, 1, 0, 0>> for Energy
impl Div<Qty<0, 0, 0, 0, 1, 0, 0>> for Energy
Source§fn div(self, rhs: Temperature) -> HeatCapacity
fn div(self, rhs: Temperature) -> HeatCapacity
/ operation. Read moreSource§impl Div<Qty<0, 0, 1, 0, 0, 0, 0>> for VelocityVec
impl Div<Qty<0, 0, 1, 0, 0, 0, 0>> for VelocityVec
Source§impl Div<Qty<0, 0, 1, 0, 0, 0, 0>> for MomentumVec
impl Div<Qty<0, 0, 1, 0, 0, 0, 0>> for MomentumVec
Source§impl Div<Qty<0, 0, 1, 0, 0, 0, 0>> for HeatCapacity
impl Div<Qty<0, 0, 1, 0, 0, 0, 0>> for HeatCapacity
Source§impl Div<Qty<0, 0, 1, 0, 0, 0, 0>> for Dimensionless
impl Div<Qty<0, 0, 1, 0, 0, 0, 0>> for Dimensionless
Source§impl Div<Qty<0, 0, -1, 0, 0, 0, 0>> for AngularMomentum
impl Div<Qty<0, 0, -1, 0, 0, 0, 0>> for AngularMomentum
Source§impl Div<Qty<0, 0, -1, 0, 0, 0, 0>> for Dimensionless
impl Div<Qty<0, 0, -1, 0, 0, 0, 0>> for Dimensionless
Source§impl Div<Qty<0, 1, 0, 0, 0, 0, 0>> for MomentumVec
impl Div<Qty<0, 1, 0, 0, 0, 0, 0>> for MomentumVec
Source§impl Div<Qty<0, 1, 0, 0, 0, 0, 0>> for MomentOfInertia
impl Div<Qty<0, 1, 0, 0, 0, 0, 0>> for MomentOfInertia
Source§impl Div<Qty<0, 1, 0, 0, 0, 0, 0>> for HeatCapacity
impl Div<Qty<0, 1, 0, 0, 0, 0, 0>> for HeatCapacity
Source§impl Div<Qty<1, 0, 0, 0, 0, 0, 0>> for Resistivity
impl Div<Qty<1, 0, 0, 0, 0, 0, 0>> for Resistivity
Source§impl Div<Qty<1, 1, -3, -1, 0, 0, 0>> for CurrentDensity
impl Div<Qty<1, 1, -3, -1, 0, 0, 0>> for CurrentDensity
Source§fn div(self, rhs: ElectricField) -> Conductivity
fn div(self, rhs: ElectricField) -> Conductivity
/ operation. Read moreSource§impl Div<Qty<2, 0, 0, 0, 0, 0, 0>> for MomentOfInertia
impl Div<Qty<2, 0, 0, 0, 0, 0, 0>> for MomentOfInertia
Source§impl Div<Qty<2, 0, -2, 0, -1, 0, 0>> for HeatCapacity
impl Div<Qty<2, 0, -2, 0, -1, 0, 0>> for HeatCapacity
Source§impl Div<Qty<2, 0, -2, 0, -1, 0, 0>> for LatentHeat
impl Div<Qty<2, 0, -2, 0, -1, 0, 0>> for LatentHeat
Source§fn div(self, rhs: SpecificHeat) -> Temperature
fn div(self, rhs: SpecificHeat) -> Temperature
/ operation. Read moreSource§impl Div<Qty<2, 1, 0, 0, 0, 0, 0>> for AngularMomentum
impl Div<Qty<2, 1, 0, 0, 0, 0, 0>> for AngularMomentum
Source§impl Div<Qty<2, 1, -2, 0, -1, 0, 0>> for Energy
impl Div<Qty<2, 1, -2, 0, -1, 0, 0>> for Energy
Source§fn div(self, rhs: HeatCapacity) -> Temperature
fn div(self, rhs: HeatCapacity) -> Temperature
/ operation. Read moreSource§impl Div<Qty<2, 1, -3, 0, -1, 0, 0>> for Power
impl Div<Qty<2, 1, -3, 0, -1, 0, 0>> for Power
Source§fn div(self, rhs: Conductance) -> Temperature
fn div(self, rhs: Conductance) -> Temperature
/ operation. Read moreSource§impl Div<Qty<2, 1, -3, 0, -1, 0, 0>> for HeatCapacity
impl Div<Qty<2, 1, -3, 0, -1, 0, 0>> for HeatCapacity
Source§impl Div<Qty<2, 1, -3, -2, 0, 0, 0>> for Resistivity
impl Div<Qty<2, 1, -3, -2, 0, 0, 0>> for Resistivity
Source§impl Div<Qty<3, 1, -3, -2, 0, 0, 0>> for ElectricField
impl Div<Qty<3, 1, -3, -2, 0, 0, 0>> for ElectricField
Source§fn div(self, rhs: Resistivity) -> CurrentDensity
fn div(self, rhs: Resistivity) -> CurrentDensity
/ operation. Read moreSource§impl Div<Qty<-2, 0, 0, 1, 0, 0, 0>> for ElectricField
impl Div<Qty<-2, 0, 0, 1, 0, 0, 0>> for ElectricField
Source§fn div(self, rhs: CurrentDensity) -> Resistivity
fn div(self, rhs: CurrentDensity) -> Resistivity
/ operation. Read moreSource§impl Div<Qty<-3, -1, 3, 2, 0, 0, 0>> for CurrentDensity
impl Div<Qty<-3, -1, 3, 2, 0, 0, 0>> for CurrentDensity
Source§fn div(self, rhs: Conductivity) -> ElectricField
fn div(self, rhs: Conductivity) -> ElectricField
/ operation. Read moreSource§impl<const L: i8, const M: i8, const T: i8, const I: i8, const K: i8, const N: i8, const J: i8> Div<f64> for Qty<L, M, T, I, K, N, J>
impl<const L: i8, const M: i8, const T: i8, const I: i8, const K: i8, const N: i8, const J: i8> Div<f64> for Qty<L, M, T, I, K, N, J>
Source§impl Mul<Qty<0, 0, 0, 0, 1, 0, 0>> for SpecificHeat
impl Mul<Qty<0, 0, 0, 0, 1, 0, 0>> for SpecificHeat
Source§fn mul(self, rhs: Temperature) -> LatentHeat
fn mul(self, rhs: Temperature) -> LatentHeat
* operation. Read moreSource§impl Mul<Qty<0, 0, 0, 0, 1, 0, 0>> for Conductance
impl Mul<Qty<0, 0, 0, 0, 1, 0, 0>> for Conductance
Source§impl Mul<Qty<0, 0, 0, 0, 1, 0, 0>> for HeatCapacity
impl Mul<Qty<0, 0, 0, 0, 1, 0, 0>> for HeatCapacity
Source§impl Mul<Qty<0, 0, 0, 1, 0, 0, 0>> for Resistance
impl Mul<Qty<0, 0, 0, 1, 0, 0, 0>> for Resistance
Source§impl Mul<Qty<0, 0, 1, 0, 0, 0, 0>> for VelocityVec
impl Mul<Qty<0, 0, 1, 0, 0, 0, 0>> for VelocityVec
Source§impl Mul<Qty<0, 0, 1, 0, 0, 0, 0>> for AccelerationVec
impl Mul<Qty<0, 0, 1, 0, 0, 0, 0>> for AccelerationVec
Source§impl Mul<Qty<0, 0, 1, 0, 0, 0, 0>> for Acceleration
impl Mul<Qty<0, 0, 1, 0, 0, 0, 0>> for Acceleration
Source§impl Mul<Qty<0, 0, 1, 0, 0, 0, 0>> for Conductance
impl Mul<Qty<0, 0, 1, 0, 0, 0, 0>> for Conductance
Source§impl Mul<Qty<0, 0, -1, 0, 0, 0, 0>> for MomentOfInertia
impl Mul<Qty<0, 0, -1, 0, 0, 0, 0>> for MomentOfInertia
Source§impl Mul<Qty<0, 1, 0, 0, 0, 0, 0>> for VelocityVec
impl Mul<Qty<0, 1, 0, 0, 0, 0, 0>> for VelocityVec
Source§impl Mul<Qty<0, 1, 0, 0, 0, 0, 0>> for AccelerationVec
impl Mul<Qty<0, 1, 0, 0, 0, 0, 0>> for AccelerationVec
Source§impl Mul<Qty<0, 1, 0, 0, 0, 0, 0>> for Acceleration
impl Mul<Qty<0, 1, 0, 0, 0, 0, 0>> for Acceleration
Source§impl Mul<Qty<0, 1, 0, 0, 0, 0, 0>> for SpecificHeat
impl Mul<Qty<0, 1, 0, 0, 0, 0, 0>> for SpecificHeat
Source§impl Mul<Qty<0, 1, 0, 0, 0, 0, 0>> for LatentHeat
impl Mul<Qty<0, 1, 0, 0, 0, 0, 0>> for LatentHeat
Source§impl Mul<Qty<0, 1, -1, 0, 0, 0, 0>> for VelocityVec
impl Mul<Qty<0, 1, -1, 0, 0, 0, 0>> for VelocityVec
Source§impl Mul<Qty<1, 0, 0, 0, 0, 0, 0>> for Resistance
impl Mul<Qty<1, 0, 0, 0, 0, 0, 0>> for Resistance
Source§impl Mul<Qty<1, 0, 0, 0, 0, 0, 0>> for ElectricField
impl Mul<Qty<1, 0, 0, 0, 0, 0, 0>> for ElectricField
Source§impl Mul<Qty<1, 1, -3, -1, 0, 0, 0>> for Conductivity
impl Mul<Qty<1, 1, -3, -1, 0, 0, 0>> for Conductivity
Source§fn mul(self, rhs: ElectricField) -> CurrentDensity
fn mul(self, rhs: ElectricField) -> CurrentDensity
* operation. Read moreSource§impl Mul<Qty<2, 0, 0, 0, 0, 0, 0>> for Irradiance
impl Mul<Qty<2, 0, 0, 0, 0, 0, 0>> for Irradiance
Source§impl Mul<Qty<2, 0, 0, 0, 0, 0, 0>> for CurrentDensity
impl Mul<Qty<2, 0, 0, 0, 0, 0, 0>> for CurrentDensity
Source§impl Mul<Qty<2, 0, -2, 0, -1, 0, 0>> for Mass
impl Mul<Qty<2, 0, -2, 0, -1, 0, 0>> for Mass
Source§fn mul(self, rhs: SpecificHeat) -> HeatCapacity
fn mul(self, rhs: SpecificHeat) -> HeatCapacity
* operation. Read moreSource§impl Mul<Qty<2, 0, -2, 0, -1, 0, 0>> for Temperature
impl Mul<Qty<2, 0, -2, 0, -1, 0, 0>> for Temperature
Source§fn mul(self, rhs: SpecificHeat) -> LatentHeat
fn mul(self, rhs: SpecificHeat) -> LatentHeat
* operation. Read moreSource§impl Mul<Qty<2, 1, 0, 0, 0, 0, 0>> for Frequency
impl Mul<Qty<2, 1, 0, 0, 0, 0, 0>> for Frequency
Source§fn mul(self, rhs: MomentOfInertia) -> AngularMomentum
fn mul(self, rhs: MomentOfInertia) -> AngularMomentum
* operation. Read moreSource§impl Mul<Qty<2, 1, -2, 0, -1, 0, 0>> for Temperature
impl Mul<Qty<2, 1, -2, 0, -1, 0, 0>> for Temperature
Source§impl Mul<Qty<2, 1, -3, 0, -1, 0, 0>> for Temperature
impl Mul<Qty<2, 1, -3, 0, -1, 0, 0>> for Temperature
Source§impl Mul<Qty<2, 1, -3, 0, -1, 0, 0>> for Time
impl Mul<Qty<2, 1, -3, 0, -1, 0, 0>> for Time
Source§fn mul(self, rhs: Conductance) -> HeatCapacity
fn mul(self, rhs: Conductance) -> HeatCapacity
* operation. Read moreSource§impl Mul<Qty<2, 1, -3, -2, 0, 0, 0>> for Length
impl Mul<Qty<2, 1, -3, -2, 0, 0, 0>> for Length
Source§fn mul(self, rhs: Resistance) -> Resistivity
fn mul(self, rhs: Resistance) -> Resistivity
* operation. Read moreSource§impl Mul<Qty<3, 1, -3, -2, 0, 0, 0>> for CurrentDensity
impl Mul<Qty<3, 1, -3, -2, 0, 0, 0>> for CurrentDensity
Source§fn mul(self, rhs: Resistivity) -> ElectricField
fn mul(self, rhs: Resistivity) -> ElectricField
* operation. Read moreSource§impl Mul<Qty<-2, 0, 0, 1, 0, 0, 0>> for Resistivity
impl Mul<Qty<-2, 0, 0, 1, 0, 0, 0>> for Resistivity
Source§fn mul(self, rhs: CurrentDensity) -> ElectricField
fn mul(self, rhs: CurrentDensity) -> ElectricField
* operation. Read moreSource§impl Mul<Qty<-3, -1, 3, 2, 0, 0, 0>> for ElectricField
impl Mul<Qty<-3, -1, 3, 2, 0, 0, 0>> for ElectricField
Source§fn mul(self, rhs: Conductivity) -> CurrentDensity
fn mul(self, rhs: Conductivity) -> CurrentDensity
* operation. Read more