pub struct NumBytes {
pub raw: u64,
}
Expand description
Represents a number of bytes.
Fields§
§raw: u64
Raw number of bytes.
Implementations§
Source§impl NumBytes
impl NumBytes
Sourcepub const fn from_usize(n: usize) -> Self
pub const fn from_usize(n: usize) -> Self
Construct NumBytes
from the provided raw number of bytes.
Sourcepub const fn to_blocks_floor(self, block_size: NumBytes) -> NumBlocks
pub const fn to_blocks_floor(self, block_size: NumBytes) -> NumBlocks
Compute a number of blocks rounding down.
Sourcepub const fn to_blocks_ceil(self, block_size: NumBytes) -> NumBlocks
pub const fn to_blocks_ceil(self, block_size: NumBytes) -> NumBlocks
Compute a number of blocks rounding up.
Sourcepub const fn split_fractional(self, unit: ByteUnit) -> (u64, u64)
pub const fn split_fractional(self, unit: ByteUnit) -> (u64, u64)
Splits the number into a whole and a fractional part based on the provided unit.
Sourcepub const fn display_unit(self) -> ByteUnit
pub const fn display_unit(self) -> ByteUnit
Unit to use when displaying the number.
Sourcepub const fn parse_str(s: &str) -> Result<NumBytes, NumBytesParseError>
pub const fn parse_str(s: &str) -> Result<NumBytes, NumBytesParseError>
Parse a byte size string.
Sourcepub const fn parse_ascii(buffer: &[u8]) -> Result<NumBytes, NumBytesParseError>
pub const fn parse_ascii(buffer: &[u8]) -> Result<NumBytes, NumBytesParseError>
Parse a byte size ASCII string.
Source§impl NumBytes
impl NumBytes
Sourcepub const fn kilobytes(n: u64) -> NumBytes
pub const fn kilobytes(n: u64) -> NumBytes
Construct NumBytes
from the given number n
of Kilobytes.
Sourcepub const fn kibibytes(n: u64) -> NumBytes
pub const fn kibibytes(n: u64) -> NumBytes
Construct NumBytes
from the given number n
of Kibibytes.
Sourcepub const fn megabytes(n: u64) -> NumBytes
pub const fn megabytes(n: u64) -> NumBytes
Construct NumBytes
from the given number n
of Megabytes.
Sourcepub const fn mebibytes(n: u64) -> NumBytes
pub const fn mebibytes(n: u64) -> NumBytes
Construct NumBytes
from the given number n
of Mebibytes.
Sourcepub const fn gigabytes(n: u64) -> NumBytes
pub const fn gigabytes(n: u64) -> NumBytes
Construct NumBytes
from the given number n
of Gigabytes.
Sourcepub const fn gibibytes(n: u64) -> NumBytes
pub const fn gibibytes(n: u64) -> NumBytes
Construct NumBytes
from the given number n
of Gibibytes.
Sourcepub const fn terabytes(n: u64) -> NumBytes
pub const fn terabytes(n: u64) -> NumBytes
Construct NumBytes
from the given number n
of Terabytes.
Sourcepub const fn tebibytes(n: u64) -> NumBytes
pub const fn tebibytes(n: u64) -> NumBytes
Construct NumBytes
from the given number n
of Tebibytes.
Sourcepub const fn petabytes(n: u64) -> NumBytes
pub const fn petabytes(n: u64) -> NumBytes
Construct NumBytes
from the given number n
of Petabytes.
Sourcepub const fn pebibytes(n: u64) -> NumBytes
pub const fn pebibytes(n: u64) -> NumBytes
Construct NumBytes
from the given number n
of Pebibytes.
Trait Implementations§
Source§impl AddAssign<NumBytes> for NumBits
impl AddAssign<NumBytes> for NumBits
Source§fn add_assign(&mut self, rhs: NumBytes)
fn add_assign(&mut self, rhs: NumBytes)
+=
operation. Read moreSource§impl AddAssign<u64> for NumBytes
impl AddAssign<u64> for NumBytes
Source§fn add_assign(&mut self, rhs: u64)
fn add_assign(&mut self, rhs: u64)
+=
operation. Read moreSource§impl AddAssign for NumBytes
impl AddAssign for NumBytes
Source§fn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
+=
operation. Read moreSource§impl DivAssign<u64> for NumBytes
impl DivAssign<u64> for NumBytes
Source§fn div_assign(&mut self, rhs: u64)
fn div_assign(&mut self, rhs: u64)
/=
operation. Read moreSource§impl DivAssign for NumBytes
impl DivAssign for NumBytes
Source§fn div_assign(&mut self, rhs: Self)
fn div_assign(&mut self, rhs: Self)
/=
operation. Read moreSource§impl MulAssign<u64> for NumBytes
impl MulAssign<u64> for NumBytes
Source§fn mul_assign(&mut self, rhs: u64)
fn mul_assign(&mut self, rhs: u64)
*=
operation. Read moreSource§impl MulAssign for NumBytes
impl MulAssign for NumBytes
Source§fn mul_assign(&mut self, rhs: Self)
fn mul_assign(&mut self, rhs: Self)
*=
operation. Read moreSource§impl Ord for NumBytes
impl Ord for NumBytes
Source§impl PartialOrd<NumBits> for NumBytes
impl PartialOrd<NumBits> for NumBytes
Source§impl PartialOrd<NumBytes> for NumBits
impl PartialOrd<NumBytes> for NumBits
Source§impl PartialOrd<NumBytes> for u64
impl PartialOrd<NumBytes> for u64
Source§impl PartialOrd<u64> for NumBytes
impl PartialOrd<u64> for NumBytes
Source§impl PartialOrd for NumBytes
impl PartialOrd for NumBytes
Source§impl SubAssign<NumBytes> for NumBits
impl SubAssign<NumBytes> for NumBits
Source§fn sub_assign(&mut self, rhs: NumBytes)
fn sub_assign(&mut self, rhs: NumBytes)
-=
operation. Read moreSource§impl SubAssign<u64> for NumBytes
impl SubAssign<u64> for NumBytes
Source§fn sub_assign(&mut self, rhs: u64)
fn sub_assign(&mut self, rhs: u64)
-=
operation. Read moreSource§impl SubAssign for NumBytes
impl SubAssign for NumBytes
Source§fn sub_assign(&mut self, rhs: Self)
fn sub_assign(&mut self, rhs: Self)
-=
operation. Read more