#[non_exhaustive]pub enum UnitBi {
Yobi = 80,
Zebi = 70,
Exbi = 60,
Pebi = 50,
Tebi = 40,
Gibi = 30,
Mebi = 20,
Kibi = 10,
None = 0,
}unit only.Expand description
Binary unit prefixes.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Yobi = 80
2^80.
Zebi = 70
2^70.
Exbi = 60
2^60.
Pebi = 50
2^50.
Tebi = 40
2^40.
Gibi = 30
2^30.
Mebi = 20
2^20.
Kibi = 10
2^10.
None = 0
2^0 (no prefix).
Implementations§
Source§impl UnitBi
impl UnitBi
Sourcepub const fn symbol_ascii(&self) -> &str ⓘ
pub const fn symbol_ascii(&self) -> &str ⓘ
Returns the ASCII symbol of the prefix.
Sourcepub const fn exp(&self) -> i32 ⓘ
pub const fn exp(&self) -> i32 ⓘ
Returns the exponent corresponding to the binary unit prefix.
For example, Mebi corresponds to an exponent of 20, meaning
Self::BASE^self.exp() = 1_048_576.
Sourcepub const fn factor(&self) -> f64 ⓘ
pub const fn factor(&self) -> f64 ⓘ
Returns the multiplication factor for the binary prefix as an f64.
Sourcepub const fn factor_i64_checked(&self) -> Option<i64> ⓘ
pub const fn factor_i64_checked(&self) -> Option<i64> ⓘ
Returns the multiplication factor for the binary prefix as an i64.
Only supports the range up to Exbi, returning None for Zebi and Yobi.
Sourcepub const fn factor_i64(&self) -> i64 ⓘ
pub const fn factor_i64(&self) -> i64 ⓘ
Returns the multiplication factor for the binary prefix as an i64.
Only supports the range up to Exbi, returning 0 for Zebi and Yobi.
Sourcepub const fn factor_i128(&self) -> i128 ⓘ
pub const fn factor_i128(&self) -> i128 ⓘ
Returns the multiplication factor for the binary prefix as an i128.
Sourcepub fn convert(value: f64, from: Self, to: Self) -> f64 ⓘ
pub fn convert(value: f64, from: Self, to: Self) -> f64 ⓘ
Converts a value from one binary prefix to another, returning the converted value.
Sourcepub fn convert_i64(value: i64, from: Self, to: Self) -> (i64, i64) ⓘ
pub fn convert_i64(value: i64, from: Self, to: Self) -> (i64, i64) ⓘ
Converts a value from one binary prefix to another, returning the converted value and the remainder.
Sourcepub fn convert_i128(value: i128, from: Self, to: Self) -> (i128, i128) ⓘ
pub fn convert_i128(value: i128, from: Self, to: Self) -> (i128, i128) ⓘ
Converts a value from one binary prefix to another, returning the converted value and the remainder.
Sourcepub fn reduce(value: f64) -> (f64, Self) ⓘ
pub fn reduce(value: f64) -> (f64, Self) ⓘ
Reduces the given value to the most appropriate binary prefix as an f64,
returning a tuple of the reduced size and the prefix.
The input value is assumed to be non-negative, and in base units,
meaning it has no prefix applied.
This method simplifies large numerical values by scaling them down to the largest appropriate binary prefix (e.g., Kibi, Mebi, Gibi, etc.).
Sourcepub const fn reduce_i64(value: i64) -> (i64, Self, i64) ⓘ
pub const fn reduce_i64(value: i64) -> (i64, Self, i64) ⓘ
Reduces the given value to the most appropriate binary prefix as an i64,
returning a tuple of the reduced size, the prefix, and the remainder.
The input value is assumed to be non-negative, and in base units,
meaning it has no prefix applied.
This method simplifies large numerical values by scaling them down to the largest appropriate binary prefix (e.g., Kibi, Mebi, Gibi, etc.).
Sourcepub const fn reduce_i128(value: i128) -> (i128, Self, i128) ⓘ
pub const fn reduce_i128(value: i128) -> (i128, Self, i128) ⓘ
Reduces the given value to the most appropriate binary prefix as an i128,
returning a tuple of the reduced size, the prefix, and the remainder.
The input value is assumed to be non-negative, and in base units,
meaning it has no prefix applied.
This method simplifies large numerical values by scaling them down to the largest appropriate binary prefix (e.g., Kibi, Mebi, Gibi, etc.).
Sourcepub fn reduce_chain(value: f64, threshold: f64) -> Vec<(f64, Self)> ⓘ
Available on crate feature alloc only.
pub fn reduce_chain(value: f64, threshold: f64) -> Vec<(f64, Self)> ⓘ
alloc only.Reduces the given value to a chain of appropriate binary prefixes as an f64,
stopping when the remainder is less than the given threshold.
Trait Implementations§
Source§impl Unit for UnitBi
impl Unit for UnitBi
Source§fn symbol_ascii(&self) -> &str ⓘ
fn symbol_ascii(&self) -> &str ⓘ
Source§fn factor_i64(&self) -> i64 ⓘ
fn factor_i64(&self) -> i64 ⓘ
Source§fn factor_i128(&self) -> i128 ⓘ
fn factor_i128(&self) -> i128 ⓘ
Source§fn asc_iter() -> impl Iterator<Item = Self>
fn asc_iter() -> impl Iterator<Item = Self>
Source§fn desc_iter() -> impl Iterator<Item = Self>
fn desc_iter() -> impl Iterator<Item = Self>
Source§fn convert(value: f64, from: Self, to: Self) -> f64 ⓘ
fn convert(value: f64, from: Self, to: Self) -> f64 ⓘ
Source§fn convert_i64(value: i64, from: Self, to: Self) -> (i64, i64) ⓘ
fn convert_i64(value: i64, from: Self, to: Self) -> (i64, i64) ⓘ
Source§fn convert_i128(value: i128, from: Self, to: Self) -> (i128, i128) ⓘ
fn convert_i128(value: i128, from: Self, to: Self) -> (i128, i128) ⓘ
Source§fn reduce(value: f64) -> (f64, Self) ⓘ
fn reduce(value: f64) -> (f64, Self) ⓘ
value to the most appropriate prefix as a f64,
returning a tuple of the reduced size and the prefix. Read moreSource§fn reduce_i64(value: i64) -> (i64, Self, i64) ⓘ
fn reduce_i64(value: i64) -> (i64, Self, i64) ⓘ
Source§fn reduce_i128(value: i128) -> (i128, Self, i128) ⓘ
fn reduce_i128(value: i128) -> (i128, Self, i128) ⓘ
Source§fn reduce_chain(value: f64, threshold: f64) -> Vec<(f64, Self)> ⓘ
fn reduce_chain(value: f64, threshold: f64) -> Vec<(f64, Self)> ⓘ
impl Copy for UnitBi
impl Eq for UnitBi
impl StructuralPartialEq for UnitBi
Auto Trait Implementations§
impl Freeze for UnitBi
impl RefUnwindSafe for UnitBi
impl UnwindSafe for UnitBi
impl Send for UnitBi
impl Sync for UnitBi
impl Unpin for UnitBi
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
Source§impl<T> ByteSized for T
impl<T> ByteSized for T
Source§const BYTE_ALIGN: usize = _
const BYTE_ALIGN: usize = _
Source§fn byte_align(&self) -> usize ⓘ
fn byte_align(&self) -> usize ⓘ
Source§fn ptr_size_ratio(&self) -> [usize; 2]
fn ptr_size_ratio(&self) -> [usize; 2]
§impl<T, R> Chain<R> for Twhere
T: ?Sized,
impl<T, R> Chain<R> for Twhere
T: ?Sized,
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Source§impl<T> ExtAny for T
impl<T> ExtAny for T
Source§fn type_hash_with<H: Hasher>(&self, hasher: H) -> u64 ⓘ
fn type_hash_with<H: Hasher>(&self, hasher: H) -> u64 ⓘ
TypeId of Self using a custom hasher.Source§fn as_any_mut(&mut self) -> &mut dyn Anywhere
Self: Sized,
fn as_any_mut(&mut self) -> &mut dyn Anywhere
Self: Sized,
Source§impl<T> ExtMem for Twhere
T: ?Sized,
impl<T> ExtMem for Twhere
T: ?Sized,
Source§const NEEDS_DROP: bool = _
const NEEDS_DROP: bool = _
Source§fn mem_align_of_val(&self) -> usize ⓘ
fn mem_align_of_val(&self) -> usize ⓘ
Source§fn mem_size_of_val(&self) -> usize ⓘ
fn mem_size_of_val(&self) -> usize ⓘ
Source§fn mem_needs_drop(&self) -> bool
fn mem_needs_drop(&self) -> bool
true if dropping values of this type matters. Read moreSource§fn mem_forget(self)where
Self: Sized,
fn mem_forget(self)where
Self: Sized,
self without running its destructor. Read moreSource§fn mem_replace(&mut self, other: Self) -> Selfwhere
Self: Sized,
fn mem_replace(&mut self, other: Self) -> Selfwhere
Self: Sized,
Source§unsafe fn mem_zeroed<T>() -> T
unsafe fn mem_zeroed<T>() -> T
unsafe_layout only.T represented by the all-zero byte-pattern. Read moreSource§unsafe fn mem_transmute_copy<Src, Dst>(src: &Src) -> Dst
unsafe fn mem_transmute_copy<Src, Dst>(src: &Src) -> Dst
unsafe_layout only.T represented by the all-zero byte-pattern. Read moreSource§fn mem_as_bytes(&self) -> &[u8] ⓘ
fn mem_as_bytes(&self) -> &[u8] ⓘ
unsafe_slice only.§impl<S> FromSample<S> for S
impl<S> FromSample<S> for S
fn from_sample_(s: S) -> S
§impl<T> Hook for T
impl<T> Hook for T
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> ⓘ
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> ⓘ
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