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: usize
Implementations§
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 subtraction overflows.
source§impl ByteLength
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_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_kilo(kibi_bytes: usize) -> ByteLength
pub const fn from_kilo(kibi_bytes: usize) -> 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_mega(mebi_bytes: usize) -> ByteLength
pub const fn from_mega(mebi_bytes: usize) -> 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_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_tebi(gibi_bytes: usize) -> ByteLength
pub const fn from_tebi(gibi_bytes: usize) -> 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.
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
impl Display for ByteLength
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 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 Twhere
T: VarValue,
impl<T> AnyVarValue for Twhere
T: VarValue,
source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
dyn Any
methods.source§fn clone_boxed(&self) -> Box<dyn AnyVarValue>
fn clone_boxed(&self) -> Box<dyn AnyVarValue>
source§fn clone_boxed_var(&self) -> Box<dyn AnyVar>
fn clone_boxed_var(&self) -> Box<dyn AnyVar>
LocalVar<Self>
.source§fn eq_any(&self, other: &(dyn AnyVarValue + 'static)) -> bool
fn eq_any(&self, other: &(dyn AnyVarValue + 'static)) -> bool
self
equals other
.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§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§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<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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