Skip to main content

BSize

Struct BSize 

Source
pub struct BSize<T: Unsigned>(pub T);
Expand description

Byte size representation.

Tuple Fields§

§0: T

Implementations§

Source§

impl BSize<u8>

Source

pub fn display(self) -> Display

Returns a display wrapper.

Source§

impl BSize<u16>

Source

pub fn display(self) -> Display

Returns a display wrapper.

Source§

impl BSize<u32>

Source

pub fn display(self) -> Display

Returns a display wrapper.

Source§

impl BSize<u64>

Source

pub fn display(self) -> Display

Returns a display wrapper.

Source§

impl BSize<usize>

Source

pub fn display(self) -> Display

Returns a display wrapper.

Source§

impl<T: Unsigned> BSize<T>

Source

pub fn with(self, f: impl FnOnce(T) -> T) -> Self

Calculate a new byte size with the provided function, returning a new struct.

Source

pub const fn b(size: T) -> Self

Constructs a byte size wrapper from a quantity of bytes.

Source§

impl BSize<u16>

Source

pub const fn kb(size: u16) -> Self

Constructs a byte size wrapper from a quantity of kb units.

Source

pub const fn kib(size: u16) -> Self

Constructs a byte size wrapper from a quantity of kib units.

Source§

impl BSize<u32>

Source

pub const fn kb(size: u32) -> Self

Constructs a byte size wrapper from a quantity of kb units.

Source

pub const fn kib(size: u32) -> Self

Constructs a byte size wrapper from a quantity of kib units.

Source

pub const fn mb(size: u32) -> Self

Constructs a byte size wrapper from a quantity of mb units.

Source

pub const fn mib(size: u32) -> Self

Constructs a byte size wrapper from a quantity of mib units.

Source

pub const fn gb(size: u32) -> Self

Constructs a byte size wrapper from a quantity of gb units.

Source

pub const fn gib(size: u32) -> Self

Constructs a byte size wrapper from a quantity of gib units.

Source§

impl BSize<u64>

Source

pub const fn kb(size: u64) -> Self

Constructs a byte size wrapper from a quantity of kb units.

Source

pub const fn kib(size: u64) -> Self

Constructs a byte size wrapper from a quantity of kib units.

Source

pub const fn mb(size: u64) -> Self

Constructs a byte size wrapper from a quantity of mb units.

Source

pub const fn mib(size: u64) -> Self

Constructs a byte size wrapper from a quantity of mib units.

Source

pub const fn gb(size: u64) -> Self

Constructs a byte size wrapper from a quantity of gb units.

Source

pub const fn gib(size: u64) -> Self

Constructs a byte size wrapper from a quantity of gib units.

Source

pub const fn tb(size: u64) -> Self

Constructs a byte size wrapper from a quantity of tb units.

Source

pub const fn tib(size: u64) -> Self

Constructs a byte size wrapper from a quantity of tib units.

Source

pub const fn pb(size: u64) -> Self

Constructs a byte size wrapper from a quantity of pb units.

Source

pub const fn pib(size: u64) -> Self

Constructs a byte size wrapper from a quantity of pib units.

Source

pub const fn eb(size: u64) -> Self

Constructs a byte size wrapper from a quantity of eb units.

Source

pub const fn eib(size: u64) -> Self

Constructs a byte size wrapper from a quantity of eib units.

Source§

impl BSize<usize>

Source

pub const fn kb(size: usize) -> Self

Constructs a byte size wrapper from a quantity of kb units.

Source

pub const fn kib(size: usize) -> Self

Constructs a byte size wrapper from a quantity of kib units.

Source§

impl BSize<usize>

Source

pub const fn mb(size: usize) -> Self

Constructs a byte size wrapper from a quantity of mb units.

Source

pub const fn mib(size: usize) -> Self

Constructs a byte size wrapper from a quantity of mib units.

Source

pub const fn gb(size: usize) -> Self

Constructs a byte size wrapper from a quantity of gb units.

Source

pub const fn gib(size: usize) -> Self

Constructs a byte size wrapper from a quantity of gib units.

Source§

impl BSize<usize>

Source

pub const fn tb(size: usize) -> Self

Constructs a byte size wrapper from a quantity of tb units.

Source

pub const fn tib(size: usize) -> Self

Constructs a byte size wrapper from a quantity of tib units.

Source

pub const fn pb(size: usize) -> Self

Constructs a byte size wrapper from a quantity of pb units.

Source

pub const fn pib(size: usize) -> Self

Constructs a byte size wrapper from a quantity of pib units.

Source

pub const fn eb(size: usize) -> Self

Constructs a byte size wrapper from a quantity of eb units.

Source

pub const fn eib(size: usize) -> Self

Constructs a byte size wrapper from a quantity of eib units.

Source§

impl BSize<u16>

Source

pub fn as_kb(&self) -> f64

Returns byte count as kilobytes.

The result is approximate when the byte count cannot be represented exactly as f64.

Source

pub fn as_kib(&self) -> f64

Returns byte count as kibibytes.

The result is approximate when the byte count cannot be represented exactly as f64.

Source§

impl BSize<u32>

Source

pub fn as_kb(&self) -> f64

Returns byte count as kilobytes.

The result is approximate when the byte count cannot be represented exactly as f64.

Source

pub fn as_kib(&self) -> f64

Returns byte count as kibibytes.

The result is approximate when the byte count cannot be represented exactly as f64.

Source

pub fn as_mb(&self) -> f64

Returns byte count as megabytes.

The result is approximate when the byte count cannot be represented exactly as f64.

Source

pub fn as_mib(&self) -> f64

Returns byte count as mebibytes.

The result is approximate when the byte count cannot be represented exactly as f64.

Source

pub fn as_gb(&self) -> f64

Returns byte count as gigabytes.

The result is approximate when the byte count cannot be represented exactly as f64.

Source

pub fn as_gib(&self) -> f64

Returns byte count as gibibytes.

The result is approximate when the byte count cannot be represented exactly as f64.

Source§

impl BSize<u64>

Source

pub fn as_kb(&self) -> f64

Returns byte count as kilobytes.

The result is approximate when the byte count cannot be represented exactly as f64.

Source

pub fn as_kib(&self) -> f64

Returns byte count as kibibytes.

The result is approximate when the byte count cannot be represented exactly as f64.

Source

pub fn as_mb(&self) -> f64

Returns byte count as megabytes.

The result is approximate when the byte count cannot be represented exactly as f64.

Source

pub fn as_mib(&self) -> f64

Returns byte count as mebibytes.

The result is approximate when the byte count cannot be represented exactly as f64.

Source

pub fn as_gb(&self) -> f64

Returns byte count as gigabytes.

The result is approximate when the byte count cannot be represented exactly as f64.

Source

pub fn as_gib(&self) -> f64

Returns byte count as gibibytes.

The result is approximate when the byte count cannot be represented exactly as f64.

Source

pub fn as_tb(&self) -> f64

Returns byte count as terabytes.

The result is approximate when the byte count cannot be represented exactly as f64.

Source

pub fn as_tib(&self) -> f64

Returns byte count as tebibytes.

The result is approximate when the byte count cannot be represented exactly as f64.

Source

pub fn as_pb(&self) -> f64

Returns byte count as petabytes.

The result is approximate when the byte count cannot be represented exactly as f64.

Source

pub fn as_pib(&self) -> f64

Returns byte count as pebibytes.

The result is approximate when the byte count cannot be represented exactly as f64.

Source

pub fn as_eb(&self) -> f64

Returns byte count as exabytes.

The result is approximate when the byte count cannot be represented exactly as f64.

Source

pub fn as_eib(&self) -> f64

Returns byte count as exbibytes.

The result is approximate when the byte count cannot be represented exactly as f64.

Source§

impl BSize<usize>

Source

pub fn as_kb(&self) -> f64

Returns byte count as kilobytes.

The result is approximate when the byte count cannot be represented exactly as f64.

Source

pub fn as_kib(&self) -> f64

Returns byte count as kibibytes.

The result is approximate when the byte count cannot be represented exactly as f64.

Source§

impl BSize<usize>

Source

pub fn as_mb(&self) -> f64

Returns byte count as megabytes.

The result is approximate when the byte count cannot be represented exactly as f64.

Source

pub fn as_mib(&self) -> f64

Returns byte count as mebibytes.

The result is approximate when the byte count cannot be represented exactly as f64.

Source

pub fn as_gb(&self) -> f64

Returns byte count as gigabytes.

The result is approximate when the byte count cannot be represented exactly as f64.

Source

pub fn as_gib(&self) -> f64

Returns byte count as gibibytes.

The result is approximate when the byte count cannot be represented exactly as f64.

Source§

impl BSize<usize>

Source

pub fn as_tb(&self) -> f64

Returns byte count as terabytes.

The result is approximate when the byte count cannot be represented exactly as f64.

Source

pub fn as_tib(&self) -> f64

Returns byte count as tebibytes.

The result is approximate when the byte count cannot be represented exactly as f64.

Source

pub fn as_pb(&self) -> f64

Returns byte count as petabytes.

The result is approximate when the byte count cannot be represented exactly as f64.

Source

pub fn as_pib(&self) -> f64

Returns byte count as pebibytes.

The result is approximate when the byte count cannot be represented exactly as f64.

Source

pub fn as_eb(&self) -> f64

Returns byte count as exabytes.

The result is approximate when the byte count cannot be represented exactly as f64.

Source

pub fn as_eib(&self) -> f64

Returns byte count as exbibytes.

The result is approximate when the byte count cannot be represented exactly as f64.

Trait Implementations§

Source§

impl Add for BSize<u8>

Source§

type Output = BSize<u8>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: BSize<u8>) -> Self::Output

Performs the + operation. Read more
Source§

impl Add for BSize<u16>

Source§

type Output = BSize<u16>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: BSize<u16>) -> Self::Output

Performs the + operation. Read more
Source§

impl Add for BSize<u32>

Source§

type Output = BSize<u32>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: BSize<u32>) -> Self::Output

Performs the + operation. Read more
Source§

impl Add for BSize<u64>

Source§

type Output = BSize<u64>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: BSize<u64>) -> Self::Output

Performs the + operation. Read more
Source§

impl Add for BSize<usize>

Source§

type Output = BSize<usize>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: BSize<usize>) -> Self::Output

Performs the + operation. Read more
Source§

impl AddAssign for BSize<u8>

Source§

fn add_assign(&mut self, rhs: BSize<u8>)

Performs the += operation. Read more
Source§

impl AddAssign for BSize<u16>

Source§

fn add_assign(&mut self, rhs: BSize<u16>)

Performs the += operation. Read more
Source§

impl AddAssign for BSize<u32>

Source§

fn add_assign(&mut self, rhs: BSize<u32>)

Performs the += operation. Read more
Source§

impl AddAssign for BSize<u64>

Source§

fn add_assign(&mut self, rhs: BSize<u64>)

Performs the += operation. Read more
Source§

impl AddAssign for BSize<usize>

Source§

fn add_assign(&mut self, rhs: BSize<usize>)

Performs the += operation. Read more
Source§

impl<T: Clone + Unsigned> Clone for BSize<T>

Source§

fn clone(&self) -> BSize<T>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Copy + Unsigned> Copy for BSize<T>

Source§

impl<T: Unsigned + Debug> Debug for BSize<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: Default + Unsigned> Default for BSize<T>

Source§

fn default() -> BSize<T>

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for BSize<u8>

Available on crate feature serde only.
Source§

fn deserialize<D>(de: D) -> Result<Self, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<'de> Deserialize<'de> for BSize<u16>

Available on crate feature serde only.
Source§

fn deserialize<D>(de: D) -> Result<Self, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<'de> Deserialize<'de> for BSize<u32>

Available on crate feature serde only.
Source§

fn deserialize<D>(de: D) -> Result<Self, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<'de> Deserialize<'de> for BSize<u64>

Available on crate feature serde only.
Source§

fn deserialize<D>(de: D) -> Result<Self, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<'de> Deserialize<'de> for BSize<usize>

Available on crate feature serde only.
Source§

fn deserialize<D>(de: D) -> Result<Self, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<T: Unsigned + Display> Display for BSize<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<T: Eq + Unsigned> Eq for BSize<T>

Source§

impl FromStr for BSize<u8>

Source§

type Err = ParseError

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl FromStr for BSize<u16>

Source§

type Err = ParseError

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl FromStr for BSize<u32>

Source§

type Err = ParseError

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl FromStr for BSize<u64>

Source§

type Err = ParseError

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl FromStr for BSize<usize>

Source§

type Err = ParseError

The associated error which can be returned from parsing.
Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more
Source§

impl<T: Hash + Unsigned> Hash for BSize<T>

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl<T: Ord + Unsigned> Ord for BSize<T>

Source§

fn cmp(&self, other: &BSize<T>) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 (const: unstable) · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 (const: unstable) · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl<T: PartialEq + Unsigned> PartialEq for BSize<T>

Source§

fn eq(&self, other: &BSize<T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T: PartialOrd + Unsigned> PartialOrd for BSize<T>

Source§

fn partial_cmp(&self, other: &BSize<T>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Serialize for BSize<u8>

Available on crate feature serde only.
Source§

fn serialize<S>(&self, ser: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Serialize for BSize<u16>

Available on crate feature serde only.
Source§

fn serialize<S>(&self, ser: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Serialize for BSize<u32>

Available on crate feature serde only.
Source§

fn serialize<S>(&self, ser: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Serialize for BSize<u64>

Available on crate feature serde only.
Source§

fn serialize<S>(&self, ser: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Serialize for BSize<usize>

Available on crate feature serde only.
Source§

fn serialize<S>(&self, ser: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<T: Unsigned> StructuralPartialEq for BSize<T>

Source§

impl Sub for BSize<u8>

Source§

type Output = BSize<u8>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: BSize<u8>) -> Self::Output

Performs the - operation. Read more
Source§

impl Sub for BSize<u16>

Source§

type Output = BSize<u16>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: BSize<u16>) -> Self::Output

Performs the - operation. Read more
Source§

impl Sub for BSize<u32>

Source§

type Output = BSize<u32>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: BSize<u32>) -> Self::Output

Performs the - operation. Read more
Source§

impl Sub for BSize<u64>

Source§

type Output = BSize<u64>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: BSize<u64>) -> Self::Output

Performs the - operation. Read more
Source§

impl Sub for BSize<usize>

Source§

type Output = BSize<usize>

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: BSize<usize>) -> Self::Output

Performs the - operation. Read more
Source§

impl SubAssign for BSize<u8>

Source§

fn sub_assign(&mut self, rhs: BSize<u8>)

Performs the -= operation. Read more
Source§

impl SubAssign for BSize<u16>

Source§

fn sub_assign(&mut self, rhs: BSize<u16>)

Performs the -= operation. Read more
Source§

impl SubAssign for BSize<u32>

Source§

fn sub_assign(&mut self, rhs: BSize<u32>)

Performs the -= operation. Read more
Source§

impl SubAssign for BSize<u64>

Source§

fn sub_assign(&mut self, rhs: BSize<u64>)

Performs the -= operation. Read more
Source§

impl SubAssign for BSize<usize>

Source§

fn sub_assign(&mut self, rhs: BSize<usize>)

Performs the -= operation. Read more

Auto Trait Implementations§

§

impl<T> Freeze for BSize<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for BSize<T>
where T: RefUnwindSafe,

§

impl<T> Send for BSize<T>
where T: Send,

§

impl<T> Sync for BSize<T>
where T: Sync,

§

impl<T> Unpin for BSize<T>
where T: Unpin,

§

impl<T> UnsafeUnpin for BSize<T>
where T: UnsafeUnpin,

§

impl<T> UnwindSafe for BSize<T>
where T: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.