Struct HumanBytes

struct HumanBytes(111)

Formats bytes for human readability

Examples

# use indicatif::HumanBytes;
assert_eq!("15 B",     format!("{}", HumanBytes(15)));
assert_eq!("1.46 KiB", format!("{}", HumanBytes(1_500)));
assert_eq!("1.43 MiB", format!("{}", HumanBytes(1_500_000)));
assert_eq!("1.40 GiB", format!("{}", HumanBytes(1_500_000_000)));
assert_eq!("1.36 TiB", format!("{}", HumanBytes(1_500_000_000_000)));
assert_eq!("1.33 PiB", format!("{}", HumanBytes(1_500_000_000_000_000)));

Implementations

impl Debug for HumanBytes

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

impl Display for HumanBytes

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

impl Freeze for HumanBytes

impl RefUnwindSafe for HumanBytes

impl Send for HumanBytes

impl Sync for HumanBytes

impl Unpin for HumanBytes

impl UnsafeUnpin for HumanBytes

impl UnwindSafe for HumanBytes

impl<T> Any for HumanBytes

fn type_id(self: &Self) -> TypeId

impl<T> Borrow for HumanBytes

fn borrow(self: &Self) -> &T

impl<T> BorrowMut for HumanBytes

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

impl<T> From for HumanBytes

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> ToString for HumanBytes

fn to_string(self: &Self) -> String

impl<T, U> Into for HumanBytes

fn into(self: Self) -> U

Calls U::from(self).

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

impl<T, U> TryFrom for HumanBytes

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

impl<T, U> TryInto for HumanBytes

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