pub struct Units {
pub systems: Vec<String>,
pub default_system: String,
pub scales: BTreeMap<String, Scale>,
pub configurations: Option<Value>,
pub default_configuration: Option<String>,
}Expand description
The whole units.json document.
Fields§
§systems: Vec<String>Named systems, in display order. Any names; not a fixed pair.
default_system: StringWhich system a machine starts in before an operator chooses.
scales: BTreeMap<String, Scale>quantity name → row.
configurations: Option<Value>Per-hardware-build overrides, resolved by
crate::config_overlay::resolve_active_config exactly like a module’s.
default_configuration: Option<String>Implementations§
Source§impl Units
impl Units
Sourcepub fn scale(&self, quantity: &str, system: &str) -> Option<&SystemScale>
pub fn scale(&self, quantity: &str, system: &str) -> Option<&SystemScale>
Resolve a quantity + system to its display treatment.
Sourcepub fn label(&self, quantity: &str, system: &str) -> Option<&str>
pub fn label(&self, quantity: &str, system: &str) -> Option<&str>
The label a quantity displays as in system.
Sourcepub fn format(&self, quantity: &str, system: &str, backend: f64) -> String
pub fn format(&self, quantity: &str, system: &str, backend: f64) -> String
Format a stored (backend) value for display.
Sourcepub fn backend_stamp(&self) -> BTreeMap<String, String>
pub fn backend_stamp(&self) -> BTreeMap<String, String>
The backend unit map — what gets stamped into a run or a method so the numbers stay self-describing (PLAN §6.4, §4.2.3).
Sourcepub fn convert_from_label(
&self,
quantity: &str,
from_label: &str,
value: f64,
) -> Result<Option<f64>, UnitsError>
pub fn convert_from_label( &self, quantity: &str, from_label: &str, value: f64, ) -> Result<Option<f64>, UnitsError>
Convert a value authored against from_label into this machine’s backend
for quantity (PLAN §4.2.3).
Ok(None) means no conversion was needed. Err means the label is not in
this machine’s table, so the caller must refuse — guessing here is how
a 1000× load command reaches a press.