Struct zng_unit::ByteLength
source · 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) -> Self
pub const fn from_byte(bytes: usize) -> Self
From bytes.
This is the same as ByteLength(bytes)
.
sourcepub const fn from_kibi(kibi_bytes: usize) -> Self
pub const fn from_kibi(kibi_bytes: usize) -> Self
From kibi-bytes.
1 kibi-byte equals 1024 bytes.
sourcepub const fn from_kilo(kibi_bytes: usize) -> Self
pub const fn from_kilo(kibi_bytes: usize) -> Self
From kilo-bytes.
1 kilo-byte equals 1000 bytes.
sourcepub const fn from_mebi(mebi_bytes: usize) -> Self
pub const fn from_mebi(mebi_bytes: usize) -> Self
From mebi-bytes.
1 mebi-byte equals 1024² bytes.
sourcepub const fn from_mega(mebi_bytes: usize) -> Self
pub const fn from_mega(mebi_bytes: usize) -> Self
From mega-bytes.
1 mega-byte equals 1000² bytes.
sourcepub const fn from_gibi(gibi_bytes: usize) -> Self
pub const fn from_gibi(gibi_bytes: usize) -> Self
From gibi-bytes.
1 gibi-byte equals 1024³ bytes.
sourcepub const fn from_giga(giga_bytes: usize) -> Self
pub const fn from_giga(giga_bytes: usize) -> Self
From giga-bytes.
1 giga-byte equals 1000³ bytes.
Trait Implementations§
source§impl Add for ByteLength
impl Add for ByteLength
source§impl AddAssign for ByteLength
impl AddAssign for ByteLength
source§fn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
+=
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<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
source§impl Display for ByteLength
impl Display for ByteLength
source§impl<S: Into<Factor>> DivAssign<S> for ByteLength
impl<S: Into<Factor>> 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§impl Hash for ByteLength
impl Hash for ByteLength
source§impl<S: Into<Factor>> MulAssign<S> for ByteLength
impl<S: Into<Factor>> 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§impl Sub for ByteLength
impl Sub for ByteLength
source§impl SubAssign for ByteLength
impl SubAssign for ByteLength
source§fn sub_assign(&mut self, rhs: Self)
fn sub_assign(&mut self, rhs: Self)
-=
operation. Read moreimpl 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> 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
)