rocket::data

Struct ByteUnit

Source
pub struct ByteUnit(/* private fields */);
Expand description

A unit of bytes with saturating const constructors and arithmetic.

§Overview

A ByteUnit represents a unit, a count, a number, of bytes. All operations on a ByteUnit – constructors, arithmetic, conversions – saturate. Overflow, underflow, and divide-by-zero are impossible. See the top-level documentation for more.

ToByteUnit provides human-friendly methods on all integer types for converting into a ByteUnit: 512.megabytes().

§Parsing

ByteUnit implements FromStr for parsing byte unit strings into a ByteUnit. The grammar accepted by the parser is:

byte_unit := uint+ ('.' uint+)? WHITESPACE* suffix

uint := '0'..'9'
suffix := case insensitive SI byte unit suffix ('b' to 'eib')
WHITESPACE := the ' ' character
use ubyte::{ByteUnit, ToByteUnit};

let one_gib: ByteUnit = "1GiB".parse().unwrap();
assert_eq!(one_gib, 1.gibibytes());

let quarter_mb: ByteUnit = "256 kB".parse().unwrap();
assert_eq!(quarter_mb, 256.kilobytes());

let half_mb: ByteUnit = "0.5MB".parse().unwrap();
assert_eq!(half_mb, 500.kilobytes());

let half_mib: ByteUnit = "0.500 mib".parse().unwrap();
assert_eq!(half_mib, 512.kibibytes());

let some_mb: ByteUnit = "20.5MB".parse().unwrap();
assert_eq!(some_mb, 20.megabytes() + 500.kilobytes());

§(De)serialization

With the serde feaure enabled (disabled by default), ByteUnit implements Deserialize from strings, using the same grammar as the FromStr implementation, defined above, as well as all integer types. The Serialize implementation serializes into a u64.

§Example

use ubyte::{ByteUnit, ToByteUnit};

// Construct with unit-valued associated constants, `const` constructors, or
// human-friendly methods from the `ToByteUnit` integer extension trait.
const HALF_GB: ByteUnit = ByteUnit::Megabyte(500);
const HALF_GIB: ByteUnit = ByteUnit::Mebibyte(512);
let half_gb = 500 * ByteUnit::MB;
let half_gib = 512 * ByteUnit::MiB;
let half_gb = 500.megabytes();
let half_gib = 512.mebibytes();

// All arithmetic operations and conversions saturate.
let exbibyte = ByteUnit::Exbibyte(1);
let exbibyte_too_large_a = 1024 * ByteUnit::EiB;
let exbibyte_too_large_b = ByteUnit::Exbibyte(1024);
let exbibyte_too_large_c = 1024.exbibytes();
let div_by_zero = 1024.exbibytes() / 0;
let too_small = 1000.megabytes() - 1.gibibytes();
assert_eq!(exbibyte << 4, ByteUnit::max_value());
assert_eq!(exbibyte << 10, ByteUnit::max_value());
assert_eq!(exbibyte_too_large_a, ByteUnit::max_value());
assert_eq!(exbibyte_too_large_b, ByteUnit::max_value());
assert_eq!(exbibyte_too_large_c, ByteUnit::max_value());
assert_eq!(div_by_zero, ByteUnit::max_value());
assert_eq!(too_small, 0);

Implementations§

Source§

impl ByteUnit

Source

pub const B: ByteUnit = _

Number of bytes in 1 B (1).

Source

pub const kB: ByteUnit = _

Number of bytes in 1 kB (1_000).

Source

pub const KiB: ByteUnit = _

Number of bytes in 1 KiB (1 << 10).

Source

pub const MB: ByteUnit = _

Number of bytes in 1 MB (1_000_000).

Source

pub const MiB: ByteUnit = _

Number of bytes in 1 MiB (1 << 20).

Source

pub const GB: ByteUnit = _

Number of bytes in 1 GB (1_000_000_000).

Source

pub const GiB: ByteUnit = _

Number of bytes in 1 GiB (1 << 30).

Source

pub const TB: ByteUnit = _

Number of bytes in 1 TB (1_000_000_000_000).

Source

pub const TiB: ByteUnit = _

Number of bytes in 1 TiB (1 << 40).

Source

pub const PB: ByteUnit = _

Number of bytes in 1 PB (1_000_000_000_000_000).

Source

pub const PiB: ByteUnit = _

Number of bytes in 1 PiB (1 << 50).

Source

pub const EB: ByteUnit = _

Number of bytes in 1 EB (1_000_000_000_000_000_000).

Source

pub const EiB: ByteUnit = _

Number of bytes in 1 EiB (1 << 60).

Source

pub const fn Byte(n: u64) -> ByteUnit

Constructs a ByteUnit representing n B .

§Example
assert_eq!(ByteUnit::Byte(10), 10 * ByteUnit::B);
Source

pub const fn Kilobyte(n: u64) -> ByteUnit

Constructs a ByteUnit representing n kB .

§Example
assert_eq!(ByteUnit::Kilobyte(10), 10 * ByteUnit::kB);
Source

pub const fn Kibibyte(n: u64) -> ByteUnit

Constructs a ByteUnit representing n KiB .

§Example
assert_eq!(ByteUnit::Kibibyte(10), 10 * ByteUnit::KiB);
Source

pub const fn Megabyte(n: u64) -> ByteUnit

Constructs a ByteUnit representing n MB .

§Example
assert_eq!(ByteUnit::Megabyte(10), 10 * ByteUnit::MB);
Source

pub const fn Mebibyte(n: u64) -> ByteUnit

Constructs a ByteUnit representing n MiB .

§Example
assert_eq!(ByteUnit::Mebibyte(10), 10 * ByteUnit::MiB);
Source

pub const fn Gigabyte(n: u64) -> ByteUnit

Constructs a ByteUnit representing n GB .

§Example
assert_eq!(ByteUnit::Gigabyte(10), 10 * ByteUnit::GB);
Source

pub const fn Gibibyte(n: u64) -> ByteUnit

Constructs a ByteUnit representing n GiB .

§Example
assert_eq!(ByteUnit::Gibibyte(10), 10 * ByteUnit::GiB);
Source

pub const fn Terabyte(n: u64) -> ByteUnit

Constructs a ByteUnit representing n TB .

§Example
assert_eq!(ByteUnit::Terabyte(10), 10 * ByteUnit::TB);
Source

pub const fn Tebibyte(n: u64) -> ByteUnit

Constructs a ByteUnit representing n TiB .

§Example
assert_eq!(ByteUnit::Tebibyte(10), 10 * ByteUnit::TiB);
Source

pub const fn Petabyte(n: u64) -> ByteUnit

Constructs a ByteUnit representing n PB .

§Example
assert_eq!(ByteUnit::Petabyte(10), 10 * ByteUnit::PB);
Source

pub const fn Pebibyte(n: u64) -> ByteUnit

Constructs a ByteUnit representing n PiB .

§Example
assert_eq!(ByteUnit::Pebibyte(10), 10 * ByteUnit::PiB);
Source

pub const fn Exabyte(n: u64) -> ByteUnit

Constructs a ByteUnit representing n EB .

§Example
assert_eq!(ByteUnit::Exabyte(10), 10 * ByteUnit::EB);
Source

pub const fn Exbibyte(n: u64) -> ByteUnit

Constructs a ByteUnit representing n EiB .

§Example
assert_eq!(ByteUnit::Exbibyte(10), 10 * ByteUnit::EiB);
Source

pub const fn max_value() -> ByteUnit

The maximum value of bytes representable by ByteUnit.

§Example
assert_eq!(ByteUnit::max_value(), u64::max_value());
Source

pub const fn as_u64(self) -> u64

Returns the value of bytes represented by self as a u64.

§Example
let int: u64 = ByteUnit::Gigabyte(4).as_u64();
assert_eq!(int, 4 * ByteUnit::GB);

assert_eq!(ByteUnit::Megabyte(42).as_u64(), 42 * 1_000_000);
assert_eq!(ByteUnit::Exbibyte(7).as_u64(), 7 * 1 << 60);
Source

pub const fn as_u128(self) -> u128

Returns the value of bytes represented by self as a u128.

§Example
let int: u128 = ByteUnit::Gigabyte(4).as_u128();
assert_eq!(int, 4 * ByteUnit::GB);

assert_eq!(ByteUnit::Megabyte(42).as_u64(), 42 * 1_000_000);
assert_eq!(ByteUnit::Exbibyte(7).as_u64(), 7 * 1 << 60);
Source

pub fn repr(self) -> (u64, f64, &'static str, ByteUnit)

Returns the components of the minimal unit representation of self.

The “minimal unit representation” is the representation that maximizes the SI-unit while minimizing the whole part of the value. For example, 1024.bytes() is minimally represented by 1KiB, while 1023.bytes() is minimally represented by 1.023kB.

The four components returned, in tuple-order, are:

  • whole - the whole part of the minimal representation.
  • frac - the fractional part of the minimal representation.
  • suffix - the suffix of the minimal representation.
  • unit - the 1-unit of the minimal representation.

Succinctly, this is: (whole, frac, suffix, unit). Observe that `(whole

  • frac) * unit` reconstructs the original value.
§Example
use ubyte::{ByteUnit, ToByteUnit};

let value = 2.mebibytes() + 512.kibibytes();
assert_eq!(value.to_string(), "2.50MiB");

let (whole, frac, suffix, unit) = value.repr();
assert_eq!(whole, 2);
assert_eq!(frac, 0.5);
assert_eq!(suffix, "MiB");
assert_eq!(unit, ByteUnit::MiB);

let reconstructed = (whole as f64 + frac) * unit.as_u64() as f64;
assert_eq!(reconstructed as u64, value);

Trait Implementations§

Source§

impl Add<ByteUnit> for i128

Source§

type Output = ByteUnit

The resulting type after applying the + operator.
Source§

fn add(self, rhs: ByteUnit) -> <i128 as Add<ByteUnit>>::Output

Performs the + operation. Read more
Source§

impl Add<ByteUnit> for i16

Source§

type Output = ByteUnit

The resulting type after applying the + operator.
Source§

fn add(self, rhs: ByteUnit) -> <i16 as Add<ByteUnit>>::Output

Performs the + operation. Read more
Source§

impl Add<ByteUnit> for i32

Source§

type Output = ByteUnit

The resulting type after applying the + operator.
Source§

fn add(self, rhs: ByteUnit) -> <i32 as Add<ByteUnit>>::Output

Performs the + operation. Read more
Source§

impl Add<ByteUnit> for i64

Source§

type Output = ByteUnit

The resulting type after applying the + operator.
Source§

fn add(self, rhs: ByteUnit) -> <i64 as Add<ByteUnit>>::Output

Performs the + operation. Read more
Source§

impl Add<ByteUnit> for i8

Source§

type Output = ByteUnit

The resulting type after applying the + operator.
Source§

fn add(self, rhs: ByteUnit) -> <i8 as Add<ByteUnit>>::Output

Performs the + operation. Read more
Source§

impl Add<ByteUnit> for isize

Source§

type Output = ByteUnit

The resulting type after applying the + operator.
Source§

fn add(self, rhs: ByteUnit) -> <isize as Add<ByteUnit>>::Output

Performs the + operation. Read more
Source§

impl Add<ByteUnit> for u128

Source§

type Output = ByteUnit

The resulting type after applying the + operator.
Source§

fn add(self, rhs: ByteUnit) -> <u128 as Add<ByteUnit>>::Output

Performs the + operation. Read more
Source§

impl Add<ByteUnit> for u16

Source§

type Output = ByteUnit

The resulting type after applying the + operator.
Source§

fn add(self, rhs: ByteUnit) -> <u16 as Add<ByteUnit>>::Output

Performs the + operation. Read more
Source§

impl Add<ByteUnit> for u32

Source§

type Output = ByteUnit

The resulting type after applying the + operator.
Source§

fn add(self, rhs: ByteUnit) -> <u32 as Add<ByteUnit>>::Output

Performs the + operation. Read more
Source§

impl Add<ByteUnit> for u64

Source§

type Output = ByteUnit

The resulting type after applying the + operator.
Source§

fn add(self, rhs: ByteUnit) -> <u64 as Add<ByteUnit>>::Output

Performs the + operation. Read more
Source§

impl Add<ByteUnit> for u8

Source§

type Output = ByteUnit

The resulting type after applying the + operator.
Source§

fn add(self, rhs: ByteUnit) -> <u8 as Add<ByteUnit>>::Output

Performs the + operation. Read more
Source§

impl Add<ByteUnit> for usize

Source§

type Output = ByteUnit

The resulting type after applying the + operator.
Source§

fn add(self, rhs: ByteUnit) -> <usize as Add<ByteUnit>>::Output

Performs the + operation. Read more
Source§

impl<T> Add<T> for ByteUnit
where T: Into<ByteUnit>,

Source§

type Output = ByteUnit

The resulting type after applying the + operator.
Source§

fn add(self, rhs: T) -> <ByteUnit as Add<T>>::Output

Performs the + operation. Read more
Source§

impl<T> AddAssign<T> for ByteUnit
where T: Into<ByteUnit>,

Source§

fn add_assign(&mut self, rhs: T)

Performs the += operation. Read more
Source§

impl Clone for ByteUnit

Source§

fn clone(&self) -> ByteUnit

Returns a copy of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for ByteUnit

Source§

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

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

impl Default for ByteUnit

Source§

fn default() -> ByteUnit

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

impl<'de> Deserialize<'de> for ByteUnit

Source§

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

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

impl Display for ByteUnit

Display self as best as possible. For perfectly custom display output, consider using ByteUnit::repr().

§Example

use ubyte::{ByteUnit, ToByteUnit};

assert_eq!(323.kilobytes().to_string(), "323kB");
assert_eq!(3.megabytes().to_string(), "3MB");
assert_eq!(3.mebibytes().to_string(), "3MiB");

assert_eq!((3.mebibytes() + 140.kilobytes()).to_string(), "3.13MiB");
assert_eq!((3.mebibytes() + 2.mebibytes()).to_string(), "5MiB");
assert_eq!((7.gigabytes() + 58.mebibytes() + 3.kilobytes()).to_string(), "7.06GB");
assert_eq!((7.gibibytes() + 920.mebibytes()).to_string(), "7.90GiB");
assert_eq!(7231.kilobytes().to_string(), "6.90MiB");

assert_eq!(format!("{:.0}", 7.gibibytes() + 920.mebibytes()), "8GiB");
assert_eq!(format!("{:.1}", 7.gibibytes() + 920.mebibytes()), "7.9GiB");
assert_eq!(format!("{:.2}", 7.gibibytes() + 920.mebibytes()), "7.90GiB");
assert_eq!(format!("{:.3}", 7.gibibytes() + 920.mebibytes()), "7.898GiB");
assert_eq!(format!("{:.4}", 7.gibibytes() + 920.mebibytes()), "7.8984GiB");
assert_eq!(format!("{:.4}", 7231.kilobytes()), "6.8960MiB");
assert_eq!(format!("{:.0}", 7231.kilobytes()), "7MiB");
assert_eq!(format!("{:.2}", 999.kilobytes() + 990.bytes()), "976.55KiB");
assert_eq!(format!("{:.0}", 999.kilobytes() + 990.bytes()), "1MB");

assert_eq!(format!("{:04.2}", 999.kilobytes() + 990.bytes()), "0976.55KiB");
assert_eq!(format!("{:02.0}", 999.kilobytes() + 990.bytes()), "01MB");
assert_eq!(format!("{:04.0}", 999.kilobytes() + 990.bytes()), "0001MB");
Source§

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

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

impl Div<ByteUnit> for i128

Source§

type Output = ByteUnit

The resulting type after applying the / operator.
Source§

fn div(self, rhs: ByteUnit) -> <i128 as Div<ByteUnit>>::Output

Performs the / operation. Read more
Source§

impl Div<ByteUnit> for i16

Source§

type Output = ByteUnit

The resulting type after applying the / operator.
Source§

fn div(self, rhs: ByteUnit) -> <i16 as Div<ByteUnit>>::Output

Performs the / operation. Read more
Source§

impl Div<ByteUnit> for i32

Source§

type Output = ByteUnit

The resulting type after applying the / operator.
Source§

fn div(self, rhs: ByteUnit) -> <i32 as Div<ByteUnit>>::Output

Performs the / operation. Read more
Source§

impl Div<ByteUnit> for i64

Source§

type Output = ByteUnit

The resulting type after applying the / operator.
Source§

fn div(self, rhs: ByteUnit) -> <i64 as Div<ByteUnit>>::Output

Performs the / operation. Read more
Source§

impl Div<ByteUnit> for i8

Source§

type Output = ByteUnit

The resulting type after applying the / operator.
Source§

fn div(self, rhs: ByteUnit) -> <i8 as Div<ByteUnit>>::Output

Performs the / operation. Read more
Source§

impl Div<ByteUnit> for isize

Source§

type Output = ByteUnit

The resulting type after applying the / operator.
Source§

fn div(self, rhs: ByteUnit) -> <isize as Div<ByteUnit>>::Output

Performs the / operation. Read more
Source§

impl Div<ByteUnit> for u128

Source§

type Output = ByteUnit

The resulting type after applying the / operator.
Source§

fn div(self, rhs: ByteUnit) -> <u128 as Div<ByteUnit>>::Output

Performs the / operation. Read more
Source§

impl Div<ByteUnit> for u16

Source§

type Output = ByteUnit

The resulting type after applying the / operator.
Source§

fn div(self, rhs: ByteUnit) -> <u16 as Div<ByteUnit>>::Output

Performs the / operation. Read more
Source§

impl Div<ByteUnit> for u32

Source§

type Output = ByteUnit

The resulting type after applying the / operator.
Source§

fn div(self, rhs: ByteUnit) -> <u32 as Div<ByteUnit>>::Output

Performs the / operation. Read more
Source§

impl Div<ByteUnit> for u64

Source§

type Output = ByteUnit

The resulting type after applying the / operator.
Source§

fn div(self, rhs: ByteUnit) -> <u64 as Div<ByteUnit>>::Output

Performs the / operation. Read more
Source§

impl Div<ByteUnit> for u8

Source§

type Output = ByteUnit

The resulting type after applying the / operator.
Source§

fn div(self, rhs: ByteUnit) -> <u8 as Div<ByteUnit>>::Output

Performs the / operation. Read more
Source§

impl Div<ByteUnit> for usize

Source§

type Output = ByteUnit

The resulting type after applying the / operator.
Source§

fn div(self, rhs: ByteUnit) -> <usize as Div<ByteUnit>>::Output

Performs the / operation. Read more
Source§

impl<T> Div<T> for ByteUnit
where T: Into<ByteUnit>,

Source§

type Output = ByteUnit

The resulting type after applying the / operator.
Source§

fn div(self, rhs: T) -> <ByteUnit as Div<T>>::Output

Performs the / operation. Read more
Source§

impl<T> DivAssign<T> for ByteUnit
where T: Into<ByteUnit>,

Source§

fn div_assign(&mut self, rhs: T)

Performs the /= operation. Read more
Source§

impl From<ByteUnit> for u128

Source§

fn from(v: ByteUnit) -> u128

Converts to this type from the input type.
Source§

impl From<ByteUnit> for u64

Source§

fn from(v: ByteUnit) -> u64

Converts to this type from the input type.
Source§

impl From<i128> for ByteUnit

Source§

fn from(value: i128) -> ByteUnit

Converts to this type from the input type.
Source§

impl From<i16> for ByteUnit

Source§

fn from(v: i16) -> ByteUnit

Converts to this type from the input type.
Source§

impl From<i32> for ByteUnit

Source§

fn from(v: i32) -> ByteUnit

Converts to this type from the input type.
Source§

impl From<i64> for ByteUnit

Source§

fn from(v: i64) -> ByteUnit

Converts to this type from the input type.
Source§

impl From<i8> for ByteUnit

Source§

fn from(v: i8) -> ByteUnit

Converts to this type from the input type.
Source§

impl From<isize> for ByteUnit

Source§

fn from(value: isize) -> ByteUnit

Converts to this type from the input type.
Source§

impl From<u128> for ByteUnit

Source§

fn from(value: u128) -> ByteUnit

Converts to this type from the input type.
Source§

impl From<u16> for ByteUnit

Source§

fn from(v: u16) -> ByteUnit

Converts to this type from the input type.
Source§

impl From<u32> for ByteUnit

Source§

fn from(v: u32) -> ByteUnit

Converts to this type from the input type.
Source§

impl From<u64> for ByteUnit

Source§

fn from(v: u64) -> ByteUnit

Converts to this type from the input type.
Source§

impl From<u8> for ByteUnit

Source§

fn from(v: u8) -> ByteUnit

Converts to this type from the input type.
Source§

impl From<usize> for ByteUnit

Source§

fn from(value: usize) -> ByteUnit

Converts to this type from the input type.
Source§

impl FromStr for ByteUnit

Source§

type Err = Error

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

fn from_str(s: &str) -> Result<ByteUnit, <ByteUnit as FromStr>::Err>

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

impl Hash for ByteUnit

Source§

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

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 Len<ByteUnit> for TempFile<'_>

Source§

fn len(&self) -> ByteUnit

The length of the value.
Source§

fn len_into_u64(len: ByteUnit) -> u64

Convert len into u64.
Source§

fn zero_len() -> ByteUnit

The zero value for L.
Source§

impl Mul<ByteUnit> for i128

Source§

type Output = ByteUnit

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: ByteUnit) -> <i128 as Mul<ByteUnit>>::Output

Performs the * operation. Read more
Source§

impl Mul<ByteUnit> for i16

Source§

type Output = ByteUnit

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: ByteUnit) -> <i16 as Mul<ByteUnit>>::Output

Performs the * operation. Read more
Source§

impl Mul<ByteUnit> for i32

Source§

type Output = ByteUnit

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: ByteUnit) -> <i32 as Mul<ByteUnit>>::Output

Performs the * operation. Read more
Source§

impl Mul<ByteUnit> for i64

Source§

type Output = ByteUnit

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: ByteUnit) -> <i64 as Mul<ByteUnit>>::Output

Performs the * operation. Read more
Source§

impl Mul<ByteUnit> for i8

Source§

type Output = ByteUnit

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: ByteUnit) -> <i8 as Mul<ByteUnit>>::Output

Performs the * operation. Read more
Source§

impl Mul<ByteUnit> for isize

Source§

type Output = ByteUnit

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: ByteUnit) -> <isize as Mul<ByteUnit>>::Output

Performs the * operation. Read more
Source§

impl Mul<ByteUnit> for u128

Source§

type Output = ByteUnit

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: ByteUnit) -> <u128 as Mul<ByteUnit>>::Output

Performs the * operation. Read more
Source§

impl Mul<ByteUnit> for u16

Source§

type Output = ByteUnit

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: ByteUnit) -> <u16 as Mul<ByteUnit>>::Output

Performs the * operation. Read more
Source§

impl Mul<ByteUnit> for u32

Source§

type Output = ByteUnit

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: ByteUnit) -> <u32 as Mul<ByteUnit>>::Output

Performs the * operation. Read more
Source§

impl Mul<ByteUnit> for u64

Source§

type Output = ByteUnit

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: ByteUnit) -> <u64 as Mul<ByteUnit>>::Output

Performs the * operation. Read more
Source§

impl Mul<ByteUnit> for u8

Source§

type Output = ByteUnit

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: ByteUnit) -> <u8 as Mul<ByteUnit>>::Output

Performs the * operation. Read more
Source§

impl Mul<ByteUnit> for usize

Source§

type Output = ByteUnit

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: ByteUnit) -> <usize as Mul<ByteUnit>>::Output

Performs the * operation. Read more
Source§

impl<T> Mul<T> for ByteUnit
where T: Into<ByteUnit>,

Source§

type Output = ByteUnit

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: T) -> <ByteUnit as Mul<T>>::Output

Performs the * operation. Read more
Source§

impl<T> MulAssign<T> for ByteUnit
where T: Into<ByteUnit>,

Source§

fn mul_assign(&mut self, rhs: T)

Performs the *= operation. Read more
Source§

impl Ord for ByteUnit

Source§

fn cmp(&self, other: &ByteUnit) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

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

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

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

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

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

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

impl PartialEq<ByteUnit> for i128

Source§

fn eq(&self, other: &ByteUnit) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · 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 PartialEq<ByteUnit> for i16

Source§

fn eq(&self, other: &ByteUnit) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · 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 PartialEq<ByteUnit> for i32

Source§

fn eq(&self, other: &ByteUnit) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · 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 PartialEq<ByteUnit> for i64

Source§

fn eq(&self, other: &ByteUnit) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · 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 PartialEq<ByteUnit> for i8

Source§

fn eq(&self, other: &ByteUnit) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · 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 PartialEq<ByteUnit> for isize

Source§

fn eq(&self, other: &ByteUnit) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · 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 PartialEq<ByteUnit> for u128

Source§

fn eq(&self, other: &ByteUnit) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · 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 PartialEq<ByteUnit> for u16

Source§

fn eq(&self, other: &ByteUnit) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · 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 PartialEq<ByteUnit> for u32

Source§

fn eq(&self, other: &ByteUnit) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · 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 PartialEq<ByteUnit> for u64

Source§

fn eq(&self, other: &ByteUnit) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · 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 PartialEq<ByteUnit> for u8

Source§

fn eq(&self, other: &ByteUnit) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · 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 PartialEq<ByteUnit> for usize

Source§

fn eq(&self, other: &ByteUnit) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · 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> PartialEq<T> for ByteUnit
where T: Into<ByteUnit> + Copy,

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · 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 PartialOrd<ByteUnit> for i128

Source§

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

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · 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 · 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 · 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 · 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 PartialOrd<ByteUnit> for i16

Source§

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

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · 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 · 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 · 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 · 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 PartialOrd<ByteUnit> for i32

Source§

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

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · 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 · 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 · 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 · 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 PartialOrd<ByteUnit> for i64

Source§

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

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · 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 · 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 · 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 · 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 PartialOrd<ByteUnit> for i8

Source§

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

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · 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 · 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 · 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 · 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 PartialOrd<ByteUnit> for isize

Source§

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

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · 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 · 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 · 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 · 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 PartialOrd<ByteUnit> for u128

Source§

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

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · 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 · 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 · 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 · 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 PartialOrd<ByteUnit> for u16

Source§

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

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · 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 · 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 · 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 · 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 PartialOrd<ByteUnit> for u32

Source§

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

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · 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 · 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 · 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 · 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 PartialOrd<ByteUnit> for u64

Source§

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

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · 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 · 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 · 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 · 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 PartialOrd<ByteUnit> for u8

Source§

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

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · 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 · 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 · 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 · 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 PartialOrd<ByteUnit> for usize

Source§

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

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · 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 · 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 · 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 · 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<T> PartialOrd<T> for ByteUnit
where T: Into<ByteUnit> + Copy,

Source§

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

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · 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 · 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 · 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 · 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 Rem<ByteUnit> for i128

Source§

type Output = ByteUnit

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: ByteUnit) -> <i128 as Rem<ByteUnit>>::Output

Performs the % operation. Read more
Source§

impl Rem<ByteUnit> for i16

Source§

type Output = ByteUnit

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: ByteUnit) -> <i16 as Rem<ByteUnit>>::Output

Performs the % operation. Read more
Source§

impl Rem<ByteUnit> for i32

Source§

type Output = ByteUnit

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: ByteUnit) -> <i32 as Rem<ByteUnit>>::Output

Performs the % operation. Read more
Source§

impl Rem<ByteUnit> for i64

Source§

type Output = ByteUnit

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: ByteUnit) -> <i64 as Rem<ByteUnit>>::Output

Performs the % operation. Read more
Source§

impl Rem<ByteUnit> for i8

Source§

type Output = ByteUnit

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: ByteUnit) -> <i8 as Rem<ByteUnit>>::Output

Performs the % operation. Read more
Source§

impl Rem<ByteUnit> for isize

Source§

type Output = ByteUnit

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: ByteUnit) -> <isize as Rem<ByteUnit>>::Output

Performs the % operation. Read more
Source§

impl Rem<ByteUnit> for u128

Source§

type Output = ByteUnit

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: ByteUnit) -> <u128 as Rem<ByteUnit>>::Output

Performs the % operation. Read more
Source§

impl Rem<ByteUnit> for u16

Source§

type Output = ByteUnit

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: ByteUnit) -> <u16 as Rem<ByteUnit>>::Output

Performs the % operation. Read more
Source§

impl Rem<ByteUnit> for u32

Source§

type Output = ByteUnit

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: ByteUnit) -> <u32 as Rem<ByteUnit>>::Output

Performs the % operation. Read more
Source§

impl Rem<ByteUnit> for u64

Source§

type Output = ByteUnit

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: ByteUnit) -> <u64 as Rem<ByteUnit>>::Output

Performs the % operation. Read more
Source§

impl Rem<ByteUnit> for u8

Source§

type Output = ByteUnit

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: ByteUnit) -> <u8 as Rem<ByteUnit>>::Output

Performs the % operation. Read more
Source§

impl Rem<ByteUnit> for usize

Source§

type Output = ByteUnit

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: ByteUnit) -> <usize as Rem<ByteUnit>>::Output

Performs the % operation. Read more
Source§

impl<T> Rem<T> for ByteUnit
where T: Into<ByteUnit>,

Source§

type Output = ByteUnit

The resulting type after applying the % operator.
Source§

fn rem(self, rhs: T) -> <ByteUnit as Rem<T>>::Output

Performs the % operation. Read more
Source§

impl<T> RemAssign<T> for ByteUnit
where T: Into<ByteUnit>,

Source§

fn rem_assign(&mut self, rhs: T)

Performs the %= operation. Read more
Source§

impl Serialize for ByteUnit

Source§

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

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

impl Shl<ByteUnit> for i128

Source§

type Output = ByteUnit

The resulting type after applying the << operator.
Source§

fn shl(self, rhs: ByteUnit) -> <i128 as Shl<ByteUnit>>::Output

Performs the << operation. Read more
Source§

impl Shl<ByteUnit> for i16

Source§

type Output = ByteUnit

The resulting type after applying the << operator.
Source§

fn shl(self, rhs: ByteUnit) -> <i16 as Shl<ByteUnit>>::Output

Performs the << operation. Read more
Source§

impl Shl<ByteUnit> for i32

Source§

type Output = ByteUnit

The resulting type after applying the << operator.
Source§

fn shl(self, rhs: ByteUnit) -> <i32 as Shl<ByteUnit>>::Output

Performs the << operation. Read more
Source§

impl Shl<ByteUnit> for i64

Source§

type Output = ByteUnit

The resulting type after applying the << operator.
Source§

fn shl(self, rhs: ByteUnit) -> <i64 as Shl<ByteUnit>>::Output

Performs the << operation. Read more
Source§

impl Shl<ByteUnit> for i8

Source§

type Output = ByteUnit

The resulting type after applying the << operator.
Source§

fn shl(self, rhs: ByteUnit) -> <i8 as Shl<ByteUnit>>::Output

Performs the << operation. Read more
Source§

impl Shl<ByteUnit> for isize

Source§

type Output = ByteUnit

The resulting type after applying the << operator.
Source§

fn shl(self, rhs: ByteUnit) -> <isize as Shl<ByteUnit>>::Output

Performs the << operation. Read more
Source§

impl Shl<ByteUnit> for u128

Source§

type Output = ByteUnit

The resulting type after applying the << operator.
Source§

fn shl(self, rhs: ByteUnit) -> <u128 as Shl<ByteUnit>>::Output

Performs the << operation. Read more
Source§

impl Shl<ByteUnit> for u16

Source§

type Output = ByteUnit

The resulting type after applying the << operator.
Source§

fn shl(self, rhs: ByteUnit) -> <u16 as Shl<ByteUnit>>::Output

Performs the << operation. Read more
Source§

impl Shl<ByteUnit> for u32

Source§

type Output = ByteUnit

The resulting type after applying the << operator.
Source§

fn shl(self, rhs: ByteUnit) -> <u32 as Shl<ByteUnit>>::Output

Performs the << operation. Read more
Source§

impl Shl<ByteUnit> for u64

Source§

type Output = ByteUnit

The resulting type after applying the << operator.
Source§

fn shl(self, rhs: ByteUnit) -> <u64 as Shl<ByteUnit>>::Output

Performs the << operation. Read more
Source§

impl Shl<ByteUnit> for u8

Source§

type Output = ByteUnit

The resulting type after applying the << operator.
Source§

fn shl(self, rhs: ByteUnit) -> <u8 as Shl<ByteUnit>>::Output

Performs the << operation. Read more
Source§

impl Shl<ByteUnit> for usize

Source§

type Output = ByteUnit

The resulting type after applying the << operator.
Source§

fn shl(self, rhs: ByteUnit) -> <usize as Shl<ByteUnit>>::Output

Performs the << operation. Read more
Source§

impl<T> Shl<T> for ByteUnit
where T: Into<ByteUnit>,

Source§

type Output = ByteUnit

The resulting type after applying the << operator.
Source§

fn shl(self, rhs: T) -> <ByteUnit as Shl<T>>::Output

Performs the << operation. Read more
Source§

impl<T> ShlAssign<T> for ByteUnit
where T: Into<ByteUnit>,

Source§

fn shl_assign(&mut self, rhs: T)

Performs the <<= operation. Read more
Source§

impl Shr<ByteUnit> for i128

Source§

type Output = ByteUnit

The resulting type after applying the >> operator.
Source§

fn shr(self, rhs: ByteUnit) -> <i128 as Shr<ByteUnit>>::Output

Performs the >> operation. Read more
Source§

impl Shr<ByteUnit> for i16

Source§

type Output = ByteUnit

The resulting type after applying the >> operator.
Source§

fn shr(self, rhs: ByteUnit) -> <i16 as Shr<ByteUnit>>::Output

Performs the >> operation. Read more
Source§

impl Shr<ByteUnit> for i32

Source§

type Output = ByteUnit

The resulting type after applying the >> operator.
Source§

fn shr(self, rhs: ByteUnit) -> <i32 as Shr<ByteUnit>>::Output

Performs the >> operation. Read more
Source§

impl Shr<ByteUnit> for i64

Source§

type Output = ByteUnit

The resulting type after applying the >> operator.
Source§

fn shr(self, rhs: ByteUnit) -> <i64 as Shr<ByteUnit>>::Output

Performs the >> operation. Read more
Source§

impl Shr<ByteUnit> for i8

Source§

type Output = ByteUnit

The resulting type after applying the >> operator.
Source§

fn shr(self, rhs: ByteUnit) -> <i8 as Shr<ByteUnit>>::Output

Performs the >> operation. Read more
Source§

impl Shr<ByteUnit> for isize

Source§

type Output = ByteUnit

The resulting type after applying the >> operator.
Source§

fn shr(self, rhs: ByteUnit) -> <isize as Shr<ByteUnit>>::Output

Performs the >> operation. Read more
Source§

impl Shr<ByteUnit> for u128

Source§

type Output = ByteUnit

The resulting type after applying the >> operator.
Source§

fn shr(self, rhs: ByteUnit) -> <u128 as Shr<ByteUnit>>::Output

Performs the >> operation. Read more
Source§

impl Shr<ByteUnit> for u16

Source§

type Output = ByteUnit

The resulting type after applying the >> operator.
Source§

fn shr(self, rhs: ByteUnit) -> <u16 as Shr<ByteUnit>>::Output

Performs the >> operation. Read more
Source§

impl Shr<ByteUnit> for u32

Source§

type Output = ByteUnit

The resulting type after applying the >> operator.
Source§

fn shr(self, rhs: ByteUnit) -> <u32 as Shr<ByteUnit>>::Output

Performs the >> operation. Read more
Source§

impl Shr<ByteUnit> for u64

Source§

type Output = ByteUnit

The resulting type after applying the >> operator.
Source§

fn shr(self, rhs: ByteUnit) -> <u64 as Shr<ByteUnit>>::Output

Performs the >> operation. Read more
Source§

impl Shr<ByteUnit> for u8

Source§

type Output = ByteUnit

The resulting type after applying the >> operator.
Source§

fn shr(self, rhs: ByteUnit) -> <u8 as Shr<ByteUnit>>::Output

Performs the >> operation. Read more
Source§

impl Shr<ByteUnit> for usize

Source§

type Output = ByteUnit

The resulting type after applying the >> operator.
Source§

fn shr(self, rhs: ByteUnit) -> <usize as Shr<ByteUnit>>::Output

Performs the >> operation. Read more
Source§

impl<T> Shr<T> for ByteUnit
where T: Into<ByteUnit>,

Source§

type Output = ByteUnit

The resulting type after applying the >> operator.
Source§

fn shr(self, rhs: T) -> <ByteUnit as Shr<T>>::Output

Performs the >> operation. Read more
Source§

impl<T> ShrAssign<T> for ByteUnit
where T: Into<ByteUnit>,

Source§

fn shr_assign(&mut self, rhs: T)

Performs the >>= operation. Read more
Source§

impl Sub<ByteUnit> for i128

Source§

type Output = ByteUnit

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: ByteUnit) -> <i128 as Sub<ByteUnit>>::Output

Performs the - operation. Read more
Source§

impl Sub<ByteUnit> for i16

Source§

type Output = ByteUnit

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: ByteUnit) -> <i16 as Sub<ByteUnit>>::Output

Performs the - operation. Read more
Source§

impl Sub<ByteUnit> for i32

Source§

type Output = ByteUnit

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: ByteUnit) -> <i32 as Sub<ByteUnit>>::Output

Performs the - operation. Read more
Source§

impl Sub<ByteUnit> for i64

Source§

type Output = ByteUnit

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: ByteUnit) -> <i64 as Sub<ByteUnit>>::Output

Performs the - operation. Read more
Source§

impl Sub<ByteUnit> for i8

Source§

type Output = ByteUnit

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: ByteUnit) -> <i8 as Sub<ByteUnit>>::Output

Performs the - operation. Read more
Source§

impl Sub<ByteUnit> for isize

Source§

type Output = ByteUnit

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: ByteUnit) -> <isize as Sub<ByteUnit>>::Output

Performs the - operation. Read more
Source§

impl Sub<ByteUnit> for u128

Source§

type Output = ByteUnit

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: ByteUnit) -> <u128 as Sub<ByteUnit>>::Output

Performs the - operation. Read more
Source§

impl Sub<ByteUnit> for u16

Source§

type Output = ByteUnit

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: ByteUnit) -> <u16 as Sub<ByteUnit>>::Output

Performs the - operation. Read more
Source§

impl Sub<ByteUnit> for u32

Source§

type Output = ByteUnit

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: ByteUnit) -> <u32 as Sub<ByteUnit>>::Output

Performs the - operation. Read more
Source§

impl Sub<ByteUnit> for u64

Source§

type Output = ByteUnit

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: ByteUnit) -> <u64 as Sub<ByteUnit>>::Output

Performs the - operation. Read more
Source§

impl Sub<ByteUnit> for u8

Source§

type Output = ByteUnit

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: ByteUnit) -> <u8 as Sub<ByteUnit>>::Output

Performs the - operation. Read more
Source§

impl Sub<ByteUnit> for usize

Source§

type Output = ByteUnit

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: ByteUnit) -> <usize as Sub<ByteUnit>>::Output

Performs the - operation. Read more
Source§

impl<T> Sub<T> for ByteUnit
where T: Into<ByteUnit>,

Source§

type Output = ByteUnit

The resulting type after applying the - operator.
Source§

fn sub(self, rhs: T) -> <ByteUnit as Sub<T>>::Output

Performs the - operation. Read more
Source§

impl<T> SubAssign<T> for ByteUnit
where T: Into<ByteUnit>,

Source§

fn sub_assign(&mut self, rhs: T)

Performs the -= operation. Read more
Source§

impl Copy for ByteUnit

Source§

impl Eq for ByteUnit

Auto Trait Implementations§

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<'a, T> AsTaggedExplicit<'a> for T
where T: 'a,

Source§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self>

Source§

impl<'a, T> AsTaggedImplicit<'a> for T
where T: 'a,

Source§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self>

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, dst: *mut u8)

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

impl<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.

§

impl<T> IntoCollection<T> for T

§

fn into_collection<A>(self) -> SmallVec<A>
where A: Array<Item = T>,

Converts self into a collection.
§

fn mapped<U, F, A>(self, f: F) -> SmallVec<A>
where F: FnMut(T) -> U, A: Array<Item = U>,

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

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

Source§

fn fg(&self, value: Color) -> Painted<&T>

Returns a styled value derived from self with the foreground set to value.

This method should be used rarely. Instead, prefer to use color-specific builder methods like red() and green(), which have the same functionality but are pithier.

§Example

Set foreground color to white using fg():

use yansi::{Paint, Color};

painted.fg(Color::White);

Set foreground color to white using white().

use yansi::Paint;

painted.white();
Source§

fn primary(&self) -> Painted<&T>

Returns self with the fg() set to Color::Primary.

§Example
println!("{}", value.primary());
Source§

fn fixed(&self, color: u8) -> Painted<&T>

Returns self with the fg() set to Color::Fixed.

§Example
println!("{}", value.fixed(color));
Source§

fn rgb(&self, r: u8, g: u8, b: u8) -> Painted<&T>

Returns self with the fg() set to Color::Rgb.

§Example
println!("{}", value.rgb(r, g, b));
Source§

fn black(&self) -> Painted<&T>

Returns self with the fg() set to Color::Black.

§Example
println!("{}", value.black());
Source§

fn red(&self) -> Painted<&T>

Returns self with the fg() set to Color::Red.

§Example
println!("{}", value.red());
Source§

fn green(&self) -> Painted<&T>

Returns self with the fg() set to Color::Green.

§Example
println!("{}", value.green());
Source§

fn yellow(&self) -> Painted<&T>

Returns self with the fg() set to Color::Yellow.

§Example
println!("{}", value.yellow());
Source§

fn blue(&self) -> Painted<&T>

Returns self with the fg() set to Color::Blue.

§Example
println!("{}", value.blue());
Source§

fn magenta(&self) -> Painted<&T>

Returns self with the fg() set to Color::Magenta.

§Example
println!("{}", value.magenta());
Source§

fn cyan(&self) -> Painted<&T>

Returns self with the fg() set to Color::Cyan.

§Example
println!("{}", value.cyan());
Source§

fn white(&self) -> Painted<&T>

Returns self with the fg() set to Color::White.

§Example
println!("{}", value.white());
Source§

fn bright_black(&self) -> Painted<&T>

Returns self with the fg() set to Color::BrightBlack.

§Example
println!("{}", value.bright_black());
Source§

fn bright_red(&self) -> Painted<&T>

Returns self with the fg() set to Color::BrightRed.

§Example
println!("{}", value.bright_red());
Source§

fn bright_green(&self) -> Painted<&T>

Returns self with the fg() set to Color::BrightGreen.

§Example
println!("{}", value.bright_green());
Source§

fn bright_yellow(&self) -> Painted<&T>

Returns self with the fg() set to Color::BrightYellow.

§Example
println!("{}", value.bright_yellow());
Source§

fn bright_blue(&self) -> Painted<&T>

Returns self with the fg() set to Color::BrightBlue.

§Example
println!("{}", value.bright_blue());
Source§

fn bright_magenta(&self) -> Painted<&T>

Returns self with the fg() set to Color::BrightMagenta.

§Example
println!("{}", value.bright_magenta());
Source§

fn bright_cyan(&self) -> Painted<&T>

Returns self with the fg() set to Color::BrightCyan.

§Example
println!("{}", value.bright_cyan());
Source§

fn bright_white(&self) -> Painted<&T>

Returns self with the fg() set to Color::BrightWhite.

§Example
println!("{}", value.bright_white());
Source§

fn bg(&self, value: Color) -> Painted<&T>

Returns a styled value derived from self with the background set to value.

This method should be used rarely. Instead, prefer to use color-specific builder methods like on_red() and on_green(), which have the same functionality but are pithier.

§Example

Set background color to red using fg():

use yansi::{Paint, Color};

painted.bg(Color::Red);

Set background color to red using on_red().

use yansi::Paint;

painted.on_red();
Source§

fn on_primary(&self) -> Painted<&T>

Returns self with the bg() set to Color::Primary.

§Example
println!("{}", value.on_primary());
Source§

fn on_fixed(&self, color: u8) -> Painted<&T>

Returns self with the bg() set to Color::Fixed.

§Example
println!("{}", value.on_fixed(color));
Source§

fn on_rgb(&self, r: u8, g: u8, b: u8) -> Painted<&T>

Returns self with the bg() set to Color::Rgb.

§Example
println!("{}", value.on_rgb(r, g, b));
Source§

fn on_black(&self) -> Painted<&T>

Returns self with the bg() set to Color::Black.

§Example
println!("{}", value.on_black());
Source§

fn on_red(&self) -> Painted<&T>

Returns self with the bg() set to Color::Red.

§Example
println!("{}", value.on_red());
Source§

fn on_green(&self) -> Painted<&T>

Returns self with the bg() set to Color::Green.

§Example
println!("{}", value.on_green());
Source§

fn on_yellow(&self) -> Painted<&T>

Returns self with the bg() set to Color::Yellow.

§Example
println!("{}", value.on_yellow());
Source§

fn on_blue(&self) -> Painted<&T>

Returns self with the bg() set to Color::Blue.

§Example
println!("{}", value.on_blue());
Source§

fn on_magenta(&self) -> Painted<&T>

Returns self with the bg() set to Color::Magenta.

§Example
println!("{}", value.on_magenta());
Source§

fn on_cyan(&self) -> Painted<&T>

Returns self with the bg() set to Color::Cyan.

§Example
println!("{}", value.on_cyan());
Source§

fn on_white(&self) -> Painted<&T>

Returns self with the bg() set to Color::White.

§Example
println!("{}", value.on_white());
Source§

fn on_bright_black(&self) -> Painted<&T>

Returns self with the bg() set to Color::BrightBlack.

§Example
println!("{}", value.on_bright_black());
Source§

fn on_bright_red(&self) -> Painted<&T>

Returns self with the bg() set to Color::BrightRed.

§Example
println!("{}", value.on_bright_red());
Source§

fn on_bright_green(&self) -> Painted<&T>

Returns self with the bg() set to Color::BrightGreen.

§Example
println!("{}", value.on_bright_green());
Source§

fn on_bright_yellow(&self) -> Painted<&T>

Returns self with the bg() set to Color::BrightYellow.

§Example
println!("{}", value.on_bright_yellow());
Source§

fn on_bright_blue(&self) -> Painted<&T>

Returns self with the bg() set to Color::BrightBlue.

§Example
println!("{}", value.on_bright_blue());
Source§

fn on_bright_magenta(&self) -> Painted<&T>

Returns self with the bg() set to Color::BrightMagenta.

§Example
println!("{}", value.on_bright_magenta());
Source§

fn on_bright_cyan(&self) -> Painted<&T>

Returns self with the bg() set to Color::BrightCyan.

§Example
println!("{}", value.on_bright_cyan());
Source§

fn on_bright_white(&self) -> Painted<&T>

Returns self with the bg() set to Color::BrightWhite.

§Example
println!("{}", value.on_bright_white());
Source§

fn attr(&self, value: Attribute) -> Painted<&T>

Enables the styling Attribute value.

This method should be used rarely. Instead, prefer to use attribute-specific builder methods like bold() and underline(), which have the same functionality but are pithier.

§Example

Make text bold using attr():

use yansi::{Paint, Attribute};

painted.attr(Attribute::Bold);

Make text bold using using bold().

use yansi::Paint;

painted.bold();
Source§

fn bold(&self) -> Painted<&T>

Returns self with the attr() set to Attribute::Bold.

§Example
println!("{}", value.bold());
Source§

fn dim(&self) -> Painted<&T>

Returns self with the attr() set to Attribute::Dim.

§Example
println!("{}", value.dim());
Source§

fn italic(&self) -> Painted<&T>

Returns self with the attr() set to Attribute::Italic.

§Example
println!("{}", value.italic());
Source§

fn underline(&self) -> Painted<&T>

Returns self with the attr() set to Attribute::Underline.

§Example
println!("{}", value.underline());

Returns self with the attr() set to Attribute::Blink.

§Example
println!("{}", value.blink());

Returns self with the attr() set to Attribute::RapidBlink.

§Example
println!("{}", value.rapid_blink());
Source§

fn invert(&self) -> Painted<&T>

Returns self with the attr() set to Attribute::Invert.

§Example
println!("{}", value.invert());
Source§

fn conceal(&self) -> Painted<&T>

Returns self with the attr() set to Attribute::Conceal.

§Example
println!("{}", value.conceal());
Source§

fn strike(&self) -> Painted<&T>

Returns self with the attr() set to Attribute::Strike.

§Example
println!("{}", value.strike());
Source§

fn quirk(&self, value: Quirk) -> Painted<&T>

Enables the yansi Quirk value.

This method should be used rarely. Instead, prefer to use quirk-specific builder methods like mask() and wrap(), which have the same functionality but are pithier.

§Example

Enable wrapping using .quirk():

use yansi::{Paint, Quirk};

painted.quirk(Quirk::Wrap);

Enable wrapping using wrap().

use yansi::Paint;

painted.wrap();
Source§

fn mask(&self) -> Painted<&T>

Returns self with the quirk() set to Quirk::Mask.

§Example
println!("{}", value.mask());
Source§

fn wrap(&self) -> Painted<&T>

Returns self with the quirk() set to Quirk::Wrap.

§Example
println!("{}", value.wrap());
Source§

fn linger(&self) -> Painted<&T>

Returns self with the quirk() set to Quirk::Linger.

§Example
println!("{}", value.linger());
Source§

fn clear(&self) -> Painted<&T>

👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear(). The clear() method will be removed in a future release.

Returns self with the quirk() set to Quirk::Clear.

§Example
println!("{}", value.clear());
Source§

fn resetting(&self) -> Painted<&T>

Returns self with the quirk() set to Quirk::Resetting.

§Example
println!("{}", value.resetting());
Source§

fn bright(&self) -> Painted<&T>

Returns self with the quirk() set to Quirk::Bright.

§Example
println!("{}", value.bright());
Source§

fn on_bright(&self) -> Painted<&T>

Returns self with the quirk() set to Quirk::OnBright.

§Example
println!("{}", value.on_bright());
Source§

fn whenever(&self, value: Condition) -> Painted<&T>

Conditionally enable styling based on whether the Condition value applies. Replaces any previous condition.

See the crate level docs for more details.

§Example

Enable styling painted only when both stdout and stderr are TTYs:

use yansi::{Paint, Condition};

painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);
Source§

fn new(self) -> Painted<Self>
where Self: Sized,

Create a new Painted with a default Style. Read more
Source§

fn paint<S>(&self, style: S) -> Painted<&Self>
where S: Into<Style>,

Apply a style wholesale to self. Any previous style is replaced. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToByteUnit for T
where T: Into<ByteUnit> + Copy,

Source§

fn bytes(self) -> ByteUnit

Converts self to a ByteUnit representing self bytes.
Source§

fn kilobytes(self) -> ByteUnit

Converts self to a ByteUnit representing self kB .
Source§

fn kibibytes(self) -> ByteUnit

Converts self to a ByteUnit representing self KiB .
Source§

fn megabytes(self) -> ByteUnit

Converts self to a ByteUnit representing self MB .
Source§

fn mebibytes(self) -> ByteUnit

Converts self to a ByteUnit representing self MiB .
Source§

fn gigabytes(self) -> ByteUnit

Converts self to a ByteUnit representing self GB .
Source§

fn gibibytes(self) -> ByteUnit

Converts self to a ByteUnit representing self GiB .
Source§

fn terabytes(self) -> ByteUnit

Converts self to a ByteUnit representing self TB .
Source§

fn tibibytes(self) -> ByteUnit

Converts self to a ByteUnit representing self TiB .
Source§

fn petabytes(self) -> ByteUnit

Converts self to a ByteUnit representing self PB .
Source§

fn pebibytes(self) -> ByteUnit

Converts self to a ByteUnit representing self PiB .
Source§

fn exabytes(self) -> ByteUnit

Converts self to a ByteUnit representing self EB .
Source§

fn exbibytes(self) -> ByteUnit

Converts self to a ByteUnit representing self EiB .
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§

default 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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

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

Source§

impl<T, Rhs> NumAssignOps<Rhs> for T
where T: AddAssign<Rhs> + SubAssign<Rhs> + MulAssign<Rhs> + DivAssign<Rhs> + RemAssign<Rhs>,

Source§

impl<T, Rhs, Output> NumOps<Rhs, Output> for T
where T: Sub<Rhs, Output = Output> + Mul<Rhs, Output = Output> + Div<Rhs, Output = Output> + Add<Rhs, Output = Output> + Rem<Rhs, Output = Output>,