Skip to main content

Module quantity

Module quantity 

Source
Expand description

This module contains the DynQuantity struct and code for:

  • Interaction with a DynQuantity: Basic arithmetic operation, conversion from and into other types, formatting, etc.
  • Parsing of strings into DynQuantitys: See from_str_impl only available if the from_str feature is enabled).
  • Serialization and deserialization: See serde_impl (only available if the serde feature is enabled).
  • Conversion from and into uom::si::Quantity : See uom_impl (only available if the uom feature is enabled).

See the documentation string of DynQuantity for more information.

Modules§

from_str_impl
Overview
serde_impl
This module is only available if the serde feature is enabled. It provides various functions which can be used to (fallible) deserialize a valid DynQuantity representation into any type T which implements TryFrom<DynQuantity>. See the docstring of DynQuantity for an overview over all possible representations.
uom_impl
This module offers a TryFrom implementation to convert from a DynQuantity to the statically-typed Quantity struct from the uom crate. This is a fallible operation, since the unit of measurement of DynQuantity is only known at runtime, while the unit of measurement of Quantity is defined at compile time via the type system.

Structs§

DynQuantity
This type represents a physical quantity via its numerical value and a unit of measurement (field exponents). The unit of measurement is not defined via the type system, but rather via the values of the Unit. This means that the unit of measurement is not fixed at compile time, but can change dynamically at runtime.

Traits§

F64RealOrComplex
This is an internal trait which is used to convert between f64 and Complex<f64>-based DynQuantity structs. It needs to be public because it is part of the type signature of DynQuantity, but it is not meant to be implemented by external types and is therefore sealed.

Functions§

to_vec
Converts a slice of DynQuantity to a vector of their values V. In constrast to to_vec_checked, this function does not check whether the units of the individual DynQuantity elements are identical.
to_vec_checked
Checks if all units of the DynQuantity elements are identical. If that is the case, it converts the slice to a vector of their values V.