pub struct QuantityUnit {
pub name: String,
pub factor: RationalInteger,
pub derived_quantity_factors: Vec<(String, i32)>,
pub decomposition: BaseQuantityVector,
pub minimum: Option<RationalInteger>,
pub maximum: Option<RationalInteger>,
pub default_magnitude: Option<RationalInteger>,
}Expand description
A single unit within a Quantity type.
factor is the conversion factor: 1 of this unit equals factor canonical units.
derived_quantity_factors stores (quantity_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_quantity_factors: Vec<(String, i32)>§decomposition: BaseQuantityVector§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 QuantityUnit
impl QuantityUnit
pub fn from_decimal_factor( name: String, decimal_factor: Decimal, derived_quantity_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
Trait Implementations§
Source§impl Clone for QuantityUnit
impl Clone for QuantityUnit
Source§fn clone(&self) -> QuantityUnit
fn clone(&self) -> QuantityUnit
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for QuantityUnit
impl Debug for QuantityUnit
Source§impl<'de> Deserialize<'de> for QuantityUnit
impl<'de> Deserialize<'de> for QuantityUnit
Source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
Deserialize this value from the given Serde deserializer. Read more
Source§impl Hash for QuantityUnit
impl Hash for QuantityUnit
Source§impl PartialEq for QuantityUnit
impl PartialEq for QuantityUnit
Source§fn eq(&self, other: &QuantityUnit) -> bool
fn eq(&self, other: &QuantityUnit) -> bool
Tests for
self and other values to be equal, and is used by ==.Source§impl Serialize for QuantityUnit
impl Serialize for QuantityUnit
impl Eq for QuantityUnit
impl StructuralPartialEq for QuantityUnit
Auto Trait Implementations§
impl Freeze for QuantityUnit
impl RefUnwindSafe for QuantityUnit
impl Send for QuantityUnit
impl Sync for QuantityUnit
impl Unpin for QuantityUnit
impl UnsafeUnpin for QuantityUnit
impl UnwindSafe for QuantityUnit
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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
Compare self to
key and return true if they are equal.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more