#[repr(i32)]
pub enum Prefix {
Show 17 variants Yocto, Zepto, Atto, Femto, Pico, Nano, Micro, Milli, Unit, Kilo, Mega, Giga, Tera, Peta, Exa, Zetta, Yotta,
}
Expand description

Represents units’ SI prefixes.

Variants

Yocto

“yocto” prefix, 1e-24

Zepto

“zepto” prefix, 1e-21

Atto

“atto” prefix, 1e-18

Femto

“femto” prefix, 1e-15

Pico

“pico” prefix, 1e-12

Nano

“nano” prefix, 1e-9

Micro

“micro” prefix, 1e-6

Milli

“milli” prefix, 1e-3

Unit

unit prefix (empty), 1

Kilo

“kilo” prefix, 1e3

Mega

“mega” prefix, 1e6

Giga

“giga” prefix, 1e9

Tera

“tera” prefix, 1e12

Peta

“peta” prefix, 1e15

Exa

“exa” prefix, 1e18

Zetta

“zetta” prefix, 1e21

Yotta

“yotta” prefix, 1e24

Implementations

Returns the exponent e for base.pow(e) to return the total scaling factor. See Base::pow().

For instance,

  • if self is -12 (“pico”), then exponent() returns -12 so that Base::B1000.pow(-12) returns the scaling factor 1e-12.

  • if self is 3 (“kilo”), then exponent() returns 3 so that Base::B1024.pow(3) returns the scaling factor 1024.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Formats the value using the given formatter. Read more

Converts a prefix into its displayable form (&'static str).

Example
use si_scale::prelude::Prefix;

let pfx = Prefix::Tera;
let a_string = format!("value: {} {}B", 1.5, pfx);

assert_eq!(a_string, "value: 1.5 TB");

Converts a &str into a Prefix if conversion is successful, otherwise return an Err.

Example
use std::str::FromStr;
use si_scale::prelude::Prefix;
use si_scale::Result;

let actual= Prefix::from_str("y");
let expected = Ok(Prefix::Yocto);
assert_eq!(actual, expected);

The associated error which can be returned from parsing.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Builds a Prefix from a i32 if successful, otherwise returns a SIUnitsError::ExponentParsing() error.

The type returned in the event of a conversion error.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

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

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.