Struct Registry

Source
pub struct Registry {
Show 13 fields pub base_units: BTreeSet<BaseUnit>, pub base_unit_long_names: BTreeMap<String, String>, pub units: BTreeMap<String, Number>, pub quantities: BTreeMap<Dimensionality, String>, pub decomposition_units: BTreeMap<Dimensionality, String>, pub prefixes: Vec<(String, Numeric)>, pub definitions: BTreeMap<String, Expr>, pub docs: BTreeMap<String, String>, pub categories: BTreeMap<String, String>, pub category_names: BTreeMap<String, String>, pub datepatterns: Vec<Vec<DatePattern>>, pub substances: BTreeMap<String, Substance>, pub substance_symbols: BTreeMap<String, String>,
}

Fields§

§base_units: BTreeSet<BaseUnit>

Contains the base units, e.g. kg, bit.

§base_unit_long_names: BTreeMap<String, String>

Mappings from short forms of base units to long forms, e.g. kgkilogram.

§units: BTreeMap<String, Number>

Contains numerical values of units.

§quantities: BTreeMap<Dimensionality, String>

Maps dimensionality to named physical quantities like energy.

§decomposition_units: BTreeMap<Dimensionality, String>

Maps dimensionality to names of SI derived units (newton, pascal, etc.) for showing simplified forms of units.

§prefixes: Vec<(String, Numeric)>

A list of prefixes that can be applied to units, like kilo.

§definitions: BTreeMap<String, Expr>

Contains the original expressions defining a unit.

§docs: BTreeMap<String, String>

Contains documentation strings.

§categories: BTreeMap<String, String>

Maps unit names to category IDs.

§category_names: BTreeMap<String, String>

Maps category IDs to display names.

§datepatterns: Vec<Vec<DatePattern>>

Used for matching date formats.

§substances: BTreeMap<String, Substance>

Objects or materials that have certain properties.

§substance_symbols: BTreeMap<String, String>

Maps elemental names (like He) to substance names (helium), used for parsing molecular formulas, e.g. H2O.

Implementations§

Source§

impl Registry

Source

pub fn canonicalize(&self, name: &str) -> Option<String>

Given a unit name, tries to find a canonical name for it.

§Examples
  • kg -> kilogram (base units are converted to long name)
  • mm -> millimeter (prefixes are converted to long form)
  • micron -> micrometer (aliases are expanded)

Trait Implementations§

Source§

impl Debug for Registry

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Registry

Source§

fn default() -> Registry

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.