Skip to main content

LinearScaledUnit

Trait LinearScaledUnit 

Source
pub trait LinearScaledUnit: Unit {
    const REF_UNIT: Self;

    // Required method
    fn scale(&self) -> AmountT;

    // Provided methods
    fn from_scale(amnt: AmountT) -> Option<Self> { ... }
    fn is_ref_unit(&self) -> bool { ... }
    fn ratio(&self, other: &Self) -> AmountT { ... }
}
Expand description

Type of units being linear scaled in terms of a reference unit.

Required Associated Constants§

Source

const REF_UNIT: Self

Unit used as reference for scaling the units.

Required Methods§

Source

fn scale(&self) -> AmountT

Returns factor so that factor * Self::REFUNIT == 1 * self.

Provided Methods§

Source

fn from_scale(amnt: AmountT) -> Option<Self>

Returns Some(unit) where unit.scale() == Some(amnt), or None if there is no such unit.

Source

fn is_ref_unit(&self) -> bool

Returns true if self is the reference unit of its unit type.

Source

fn ratio(&self, other: &Self) -> AmountT

Returns factor so that factor * other == 1 * self.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl LinearScaledUnit for AccelerationUnit

Source§

const REF_UNIT: Self = Self::MeterPerSecondSquared

Source§

impl LinearScaledUnit for AreaUnit

Source§

const REF_UNIT: Self = Self::SquareMeter

Source§

impl LinearScaledUnit for DataThroughputUnit

Source§

const REF_UNIT: Self = Self::BytePerSecond

Source§

impl LinearScaledUnit for DataVolumeUnit

Source§

const REF_UNIT: Self = Self::Byte

Source§

impl LinearScaledUnit for DurationUnit

Source§

const REF_UNIT: Self = Self::Second

Source§

impl LinearScaledUnit for EnergyUnit

Source§

const REF_UNIT: Self = Self::Joule

Source§

impl LinearScaledUnit for ForceUnit

Source§

const REF_UNIT: Self = Self::Newton

Source§

impl LinearScaledUnit for FrequencyUnit

Source§

const REF_UNIT: Self = Self::Hertz

Source§

impl LinearScaledUnit for LengthUnit

Source§

const REF_UNIT: Self = Self::Meter

Source§

impl LinearScaledUnit for MassUnit

Source§

const REF_UNIT: Self = Self::Kilogram

Source§

impl LinearScaledUnit for One

Source§

const REF_UNIT: Self = ONE

Source§

impl LinearScaledUnit for PowerUnit

Source§

const REF_UNIT: Self = Self::Watt

Source§

impl LinearScaledUnit for SpeedUnit

Source§

const REF_UNIT: Self = Self::MeterPerSecond

Source§

impl LinearScaledUnit for VolumeUnit

Source§

const REF_UNIT: Self = Self::CubicMeter