Trait shadow_rs::utility::units::Prefix

source ·
pub trait Prefix:
    Clone
    + Copy
    + Default
    + PartialEq
    + FromStr
    + Display
    + Debug {
    // Required method
    fn relative_magnitude(&self) -> u128;

    // Provided methods
    fn conversion_factor(&self, to: Self) -> Result<u128, String> { ... }
    fn conversion_factor_lossy(&self, to: Self) -> f64 { ... }
}
Expand description

The prefix of a unit value denoting magnitude. Common prefixes are SI prefixes (nano, micro, milli, etc).

Required Methods§

source

fn relative_magnitude(&self) -> u128

The magnitude of this prefix relative to other prefixes of this type.

Provided Methods§

source

fn conversion_factor(&self, to: Self) -> Result<u128, String>

An integer conversion factor.

source

fn conversion_factor_lossy(&self, to: Self) -> f64

A floating point conversion factor.

Object Safety§

This trait is not object safe.

Implementors§