Skip to main content

UnitKind

Enum UnitKind 

Source
pub enum UnitKind {
    Si {
        unit_type: Arc<str>,
        name: Arc<str>,
        prefix: Option<Arc<str>>,
        prefix_exponent: Option<i32>,
    },
    Conversion {
        unit_type: Arc<str>,
        name: Option<Arc<str>>,
        factor: Option<f64>,
        factor_unit: Option<EntityId>,
        offset: Option<f64>,
    },
    Derived {
        unit_type: Arc<str>,
        elements: Vec<(EntityId, i64)>,
    },
    Monetary {
        currency: Option<Arc<str>>,
    },
    ContextDependent {
        unit_type: Arc<str>,
    },
}
Expand description

A unit as the file states it.

Variants§

§

Si

IfcSIUnit: a base SI unit with an optional decimal prefix.

Fields

§unit_type: Arc<str>

IfcUnitEnum, e.g. LENGTHUNIT.

§name: Arc<str>

IfcSIUnitName, e.g. METRE.

§prefix: Option<Arc<str>>

IfcSIPrefix, e.g. MILLI. None means unprefixed.

§prefix_exponent: Option<i32>

Decimal exponent of the prefix: MILLI is Some(-3), absent is Some(0), and a prefix that is not an IfcSIPrefix is None.

Exposed as an exponent rather than a factor so callers can apply it exactly instead of multiplying by a rounded 0.001. An unknown prefix is not read as “unprefixed”: that would silently rescale every value in the unit.

§

Conversion

IfcConversionBasedUnit: a named unit defined by a factor.

Fields

§unit_type: Arc<str>

IfcUnitEnum.

§name: Option<Arc<str>>

The unit’s name, e.g. inch.

§factor: Option<f64>

The numeric conversion factor, when readable.

§factor_unit: Option<EntityId>

The unit the factor is expressed in.

§offset: Option<f64>

IfcConversionBasedUnitWithOffset.ConversionOffset, as stated.

None for a plain conversion-based unit. Kept raw: IFC4’s own documentation contradicts itself on which direction the offset applies, so this crate does not apply it.

§

Derived

IfcDerivedUnit: a product of powers of other units.

Fields

§unit_type: Arc<str>

IfcDerivedUnitEnum, e.g. VOLUMETRICFLOWRATEUNIT.

§elements: Vec<(EntityId, i64)>

The (unit, exponent) elements.

§

Monetary

IfcMonetaryUnit: a currency, with no dimension.

Fields

§currency: Option<Arc<str>>

ISO currency code as stated.

§

ContextDependent

IfcContextDependentUnit or another named unit form.

Fields

§unit_type: Arc<str>

IfcUnitEnum.

Implementations§

Source§

impl UnitKind

Source

pub fn unit_type(&self) -> Option<&str>

The IfcUnitEnum this unit declares, when it has one.

IfcMonetaryUnit has none: it is not an IfcNamedUnit.

Source

pub fn si_scale(&self) -> Option<f64>

Multiplier converting a value in this unit to the unprefixed SI unit.

The prefix is raised to the unit’s power: MILLI SQUARE_METRE gives 1e-6 and MILLI CUBIC_METRE 1e-9. None for an unknown prefix.

Only defined for Si: a conversion-based unit needs its factor unit resolved too, and a derived unit needs its elements combined, so neither can answer honestly on its own. crate::exact_unit resolves all three to the SI base unit.

Trait Implementations§

Source§

impl Clone for UnitKind

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for UnitKind

Source§

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

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

impl PartialEq for UnitKind

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for UnitKind

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.