pub struct MeasureUnit {
pub name: String,
pub factor: RationalInteger,
pub derived_measure_factors: Vec<(String, i32)>,
pub decomposition: BTreeMap<String, i32>,
pub minimum: Option<RationalInteger>,
pub maximum: Option<RationalInteger>,
pub default_magnitude: Option<RationalInteger>,
}Expand description
A single unit within a Measure type.
factor is the conversion factor: 1 of this unit equals factor canonical units.
derived_measure_factors stores (measure_ref, exponent) pairs from compound unit declarations
(e.g., meter/second produces [("meter", 1), ("second", -1)]). Empty for base units.
decomposition is the dimensional decomposition vector, populated during the planning
decomposition pass. It is empty until that pass completes.
Fields§
§name: String§factor: RationalIntegerConversion factor: 1 of this unit equals value canonical units.
derived_measure_factors: Vec<(String, i32)>§decomposition: BTreeMap<String, i32>§minimum: Option<RationalInteger>Minimum magnitude in this unit (schema/UI); canonical bound is on the type.
maximum: Option<RationalInteger>Maximum magnitude in this unit (schema/UI).
default_magnitude: Option<RationalInteger>Default suggestion magnitude in this unit (schema/UI).
Implementations§
Source§impl MeasureUnit
impl MeasureUnit
pub fn from_decimal_factor( name: String, decimal_factor: Decimal, derived_measure_factors: Vec<(String, i32)>, ) -> Result<Self, String>
pub fn clear_constraint_magnitudes(&mut self)
pub fn is_canonical_factor(&self) -> bool
pub fn is_positive_factor(&self) -> bool
Sourcepub fn factor_decimal(&self) -> Decimal
pub fn factor_decimal(&self) -> Decimal
Conversion factor as decimal (schema unit factors always commit).
pub fn minimum_decimal(&self) -> Option<Decimal>
pub fn maximum_decimal(&self) -> Option<Decimal>
pub fn default_magnitude_decimal(&self) -> Option<Decimal>
Sourcepub fn maximum_canonical_decimal(&self) -> Option<Decimal>
pub fn maximum_canonical_decimal(&self) -> Option<Decimal>
Maximum bound lifted to canonical units via maximum * factor.
Source§impl MeasureUnit
impl MeasureUnit
pub fn with_decomposition(self, decomposition: BTreeMap<String, i32>) -> Self
pub fn with_factor(self, factor: RationalInteger) -> Self
pub fn with_derived_measure_factors( self, derived_measure_factors: Vec<(String, i32)>, ) -> Self
Trait Implementations§
Source§impl Clone for MeasureUnit
impl Clone for MeasureUnit
Source§fn clone(&self) -> MeasureUnit
fn clone(&self) -> MeasureUnit
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for MeasureUnit
impl Debug for MeasureUnit
Source§impl<'de> Deserialize<'de> for MeasureUnit
impl<'de> Deserialize<'de> for MeasureUnit
Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
impl Eq for MeasureUnit
Source§impl Hash for MeasureUnit
impl Hash for MeasureUnit
Source§impl PartialEq for MeasureUnit
impl PartialEq for MeasureUnit
Source§fn eq(&self, other: &MeasureUnit) -> bool
fn eq(&self, other: &MeasureUnit) -> bool
self and other values to be equal, and is used by ==.Source§impl Serialize for MeasureUnit
impl Serialize for MeasureUnit
impl StructuralPartialEq for MeasureUnit
Auto Trait Implementations§
impl Freeze for MeasureUnit
impl RefUnwindSafe for MeasureUnit
impl Send for MeasureUnit
impl Sync for MeasureUnit
impl Unpin for MeasureUnit
impl UnsafeUnpin for MeasureUnit
impl UnwindSafe for MeasureUnit
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.