pub struct ByteLength(pub usize);Expand description
A length in bytes.
The value is stored in bytes, you can use associated functions to convert from other units or
you can use the ByteUnits extension methods to initialize from an integer literal.
Tuple Fields§
§0: usizeImplementations§
Source§impl ByteLength
impl ByteLength
Sourcepub const MAX: ByteLength
pub const MAX: ByteLength
Maximum representable byte length.
Sourcepub const fn saturating_add(self, rhs: ByteLength) -> ByteLength
pub const fn saturating_add(self, rhs: ByteLength) -> ByteLength
Adds the two lengths without overflowing or wrapping.
Sourcepub const fn saturating_sub(self, rhs: ByteLength) -> ByteLength
pub const fn saturating_sub(self, rhs: ByteLength) -> ByteLength
Subtracts the two lengths without overflowing or wrapping.
Sourcepub const fn saturating_mul(self, rhs: ByteLength) -> ByteLength
pub const fn saturating_mul(self, rhs: ByteLength) -> ByteLength
Multiplies the two lengths without overflowing or wrapping.
Sourcepub const fn wrapping_add(self, rhs: ByteLength) -> ByteLength
pub const fn wrapping_add(self, rhs: ByteLength) -> ByteLength
Adds the two lengths wrapping overflows.
Sourcepub const fn wrapping_sub(self, rhs: ByteLength) -> ByteLength
pub const fn wrapping_sub(self, rhs: ByteLength) -> ByteLength
Subtracts the two lengths wrapping overflows.
Sourcepub const fn wrapping_mul(self, rhs: ByteLength) -> ByteLength
pub const fn wrapping_mul(self, rhs: ByteLength) -> ByteLength
Multiplies the two lengths wrapping overflows.
Sourcepub const fn wrapping_div(self, rhs: ByteLength) -> ByteLength
pub const fn wrapping_div(self, rhs: ByteLength) -> ByteLength
Divides the two lengths wrapping overflows.
Sourcepub fn checked_add(self, rhs: ByteLength) -> Option<ByteLength>
pub fn checked_add(self, rhs: ByteLength) -> Option<ByteLength>
Adds the two lengths, returns None if the sum overflows.
Sourcepub fn checked_sub(self, rhs: ByteLength) -> Option<ByteLength>
pub fn checked_sub(self, rhs: ByteLength) -> Option<ByteLength>
Subtracts the two lengths, returns None if the subtraction overflows.
Sourcepub fn checked_mul(self, rhs: ByteLength) -> Option<ByteLength>
pub fn checked_mul(self, rhs: ByteLength) -> Option<ByteLength>
Multiplies the two lengths, returns None if the sum overflows.
Sourcepub fn checked_div(self, rhs: ByteLength) -> Option<ByteLength>
pub fn checked_div(self, rhs: ByteLength) -> Option<ByteLength>
Divides the two lengths, returns None if the division overflows.
Source§impl ByteLength
Constructors
impl ByteLength
Constructors
Sourcepub const fn from_byte(bytes: usize) -> ByteLength
pub const fn from_byte(bytes: usize) -> ByteLength
From bytes.
This is the same as ByteLength(bytes).
Sourcepub const fn from_byte_f64(bytes: f64) -> ByteLength
pub const fn from_byte_f64(bytes: f64) -> ByteLength
From fractional bytes.
Just rounds the value.
Sourcepub const fn from_kibi(kibi_bytes: usize) -> ByteLength
pub const fn from_kibi(kibi_bytes: usize) -> ByteLength
From kibi-bytes.
1 kibi-byte equals 1024 bytes.
Sourcepub const fn from_kibi_f64(kibi_bytes: f64) -> ByteLength
pub const fn from_kibi_f64(kibi_bytes: f64) -> ByteLength
From kibi-bytes.
1 kibi-byte equals 1024 bytes.
Sourcepub const fn from_kilo(kilo_bytes: usize) -> ByteLength
pub const fn from_kilo(kilo_bytes: usize) -> ByteLength
From kilo-bytes.
1 kilo-byte equals 1000 bytes.
Sourcepub const fn from_kilo_f64(kilo_bytes: f64) -> ByteLength
pub const fn from_kilo_f64(kilo_bytes: f64) -> ByteLength
From kilo-bytes.
1 kilo-byte equals 1000 bytes.
Sourcepub const fn from_mebi(mebi_bytes: usize) -> ByteLength
pub const fn from_mebi(mebi_bytes: usize) -> ByteLength
From mebi-bytes.
1 mebi-byte equals 1024² bytes.
Sourcepub const fn from_mebi_f64(mebi_bytes: f64) -> ByteLength
pub const fn from_mebi_f64(mebi_bytes: f64) -> ByteLength
From mebi-bytes.
1 mebi-byte equals 1024² bytes.
Sourcepub const fn from_mega(mega_bytes: usize) -> ByteLength
pub const fn from_mega(mega_bytes: usize) -> ByteLength
From mega-bytes.
1 mega-byte equals 1000² bytes.
Sourcepub const fn from_mega_f64(mebi_bytes: f64) -> ByteLength
pub const fn from_mega_f64(mebi_bytes: f64) -> ByteLength
From mega-bytes.
1 mega-byte equals 1000² bytes.
Sourcepub const fn from_gibi(gibi_bytes: usize) -> ByteLength
pub const fn from_gibi(gibi_bytes: usize) -> ByteLength
From gibi-bytes.
1 gibi-byte equals 1024³ bytes.
Sourcepub const fn from_gibi_f64(gibi_bytes: f64) -> ByteLength
pub const fn from_gibi_f64(gibi_bytes: f64) -> ByteLength
From gibi-bytes.
1 gibi-byte equals 1024³ bytes.
Sourcepub const fn from_giga(giga_bytes: usize) -> ByteLength
pub const fn from_giga(giga_bytes: usize) -> ByteLength
From giga-bytes.
1 giga-byte equals 1000³ bytes.
Sourcepub const fn from_giga_f64(giga_bytes: f64) -> ByteLength
pub const fn from_giga_f64(giga_bytes: f64) -> ByteLength
From giga-bytes.
1 giga-byte equals 1000³ bytes.
Sourcepub const fn from_tebi(tebi_bytes: usize) -> ByteLength
pub const fn from_tebi(tebi_bytes: usize) -> ByteLength
From tebi-bytes.
1 tebi-byte equals 1024^4 bytes.
Sourcepub const fn from_tebi_f64(tebi_bytes: f64) -> ByteLength
pub const fn from_tebi_f64(tebi_bytes: f64) -> ByteLength
From tebi-bytes.
1 tebi-byte equals 1024^4 bytes.
Sourcepub const fn from_tera(tera_bytes: usize) -> ByteLength
pub const fn from_tera(tera_bytes: usize) -> ByteLength
From tera-bytes.
1 tera-byte equals 1000^4 bytes.
Sourcepub const fn from_tera_f64(tera_bytes: f64) -> ByteLength
pub const fn from_tera_f64(tera_bytes: f64) -> ByteLength
From tera-bytes.
1 tera-byte equals 1000^4 bytes.
Source§impl ByteLength
impl ByteLength
Sourcepub fn max(self, other: ByteLength) -> ByteLength
pub fn max(self, other: ByteLength) -> ByteLength
Compares and returns the maximum of two lengths.
Sourcepub fn min(self, other: ByteLength) -> ByteLength
pub fn min(self, other: ByteLength) -> ByteLength
Compares and returns the minimum of two lengths.
Trait Implementations§
Source§impl Add for ByteLength
impl Add for ByteLength
Source§type Output = ByteLength
type Output = ByteLength
+ operator.Source§fn add(self, rhs: ByteLength) -> <ByteLength as Add>::Output
fn add(self, rhs: ByteLength) -> <ByteLength as Add>::Output
+ operation. Read moreSource§impl AddAssign for ByteLength
impl AddAssign for ByteLength
Source§fn add_assign(&mut self, rhs: ByteLength)
fn add_assign(&mut self, rhs: ByteLength)
+= operation. Read moreSource§impl Clone for ByteLength
impl Clone for ByteLength
Source§fn clone(&self) -> ByteLength
fn clone(&self) -> ByteLength
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ByteLength
impl Debug for ByteLength
Source§impl Default for ByteLength
impl Default for ByteLength
Source§fn default() -> ByteLength
fn default() -> ByteLength
Source§impl<'de> Deserialize<'de> for ByteLength
impl<'de> Deserialize<'de> for ByteLength
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<ByteLength, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<ByteLength, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl Display for ByteLength
Alternative mode prints in binary units (kibi, mebi, gibi, tebi)
impl Display for ByteLength
Alternative mode prints in binary units (kibi, mebi, gibi, tebi)
Source§impl<S> Div<S> for ByteLength
impl<S> Div<S> for ByteLength
Source§type Output = ByteLength
type Output = ByteLength
/ operator.Source§fn div(self, rhs: S) -> ByteLength
fn div(self, rhs: S) -> ByteLength
/ operation. Read moreSource§impl<S> DivAssign<S> for ByteLength
impl<S> DivAssign<S> for ByteLength
Source§fn div_assign(&mut self, rhs: S)
fn div_assign(&mut self, rhs: S)
/= operation. Read moreSource§impl From<usize> for ByteLength
impl From<usize> for ByteLength
Source§fn from(value: usize) -> ByteLength
fn from(value: usize) -> ByteLength
Source§impl FromStr for ByteLength
Parses "##", "##TiB", "##GiB", "##MiB", "##KiB", "##B", "##TB", "##GB", "##MB", "##kB" and "##B" where ## is an usize.
impl FromStr for ByteLength
Parses "##", "##TiB", "##GiB", "##MiB", "##KiB", "##B", "##TB", "##GB", "##MB", "##kB" and "##B" where ## is an usize.
Source§type Err = ParseFloatError
type Err = ParseFloatError
Source§fn from_str(s: &str) -> Result<ByteLength, <ByteLength as FromStr>::Err>
fn from_str(s: &str) -> Result<ByteLength, <ByteLength as FromStr>::Err>
s to return a value of this type. Read moreSource§impl Hash for ByteLength
impl Hash for ByteLength
Source§impl<S> Mul<S> for ByteLength
impl<S> Mul<S> for ByteLength
Source§type Output = ByteLength
type Output = ByteLength
* operator.Source§fn mul(self, rhs: S) -> ByteLength
fn mul(self, rhs: S) -> ByteLength
* operation. Read moreSource§impl<S> MulAssign<S> for ByteLength
impl<S> MulAssign<S> for ByteLength
Source§fn mul_assign(&mut self, rhs: S)
fn mul_assign(&mut self, rhs: S)
*= operation. Read moreSource§impl Ord for ByteLength
impl Ord for ByteLength
Source§fn cmp(&self, other: &ByteLength) -> Ordering
fn cmp(&self, other: &ByteLength) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for ByteLength
impl PartialEq for ByteLength
Source§impl PartialOrd for ByteLength
impl PartialOrd for ByteLength
Source§impl Serialize for ByteLength
impl Serialize for ByteLength
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Source§impl Sub for ByteLength
impl Sub for ByteLength
Source§type Output = ByteLength
type Output = ByteLength
- operator.Source§fn sub(self, rhs: ByteLength) -> <ByteLength as Sub>::Output
fn sub(self, rhs: ByteLength) -> <ByteLength as Sub>::Output
- operation. Read moreSource§impl SubAssign for ByteLength
impl SubAssign for ByteLength
Source§fn sub_assign(&mut self, rhs: ByteLength)
fn sub_assign(&mut self, rhs: ByteLength)
-= operation. Read moreSource§impl Transitionable for ByteLength
impl Transitionable for ByteLength
Source§fn lerp(self, to: &ByteLength, step: Factor) -> ByteLength
fn lerp(self, to: &ByteLength, step: Factor) -> ByteLength
self -> to by step.impl Copy for ByteLength
impl Eq for ByteLength
impl StructuralPartialEq for ByteLength
Auto Trait Implementations§
impl Freeze for ByteLength
impl RefUnwindSafe for ByteLength
impl Send for ByteLength
impl Sync for ByteLength
impl Unpin for ByteLength
impl UnwindSafe for ByteLength
Blanket Implementations§
Source§impl<T> AnyVarValue for T
impl<T> AnyVarValue for T
Source§fn clone_boxed(&self) -> BoxAnyVarValue
fn clone_boxed(&self) -> BoxAnyVarValue
Source§fn eq_any(&self, other: &(dyn AnyVarValue + 'static)) -> bool
fn eq_any(&self, other: &(dyn AnyVarValue + 'static)) -> bool
self and other are equal.Source§fn try_swap(&mut self, other: &mut (dyn AnyVarValue + 'static)) -> bool
fn try_swap(&mut self, other: &mut (dyn AnyVarValue + 'static)) -> bool
other if both are of the same type.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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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