Struct byte_unit::AdjustedByte

source ·
pub struct AdjustedByte(_);
Expand description

Generated from the get_appropriate_unit and get_adjusted_unit methods of a Byte object.

Implementations

Format the AdjustedByte object to string.

Examples
extern crate byte_unit;

use byte_unit::{Byte, ByteUnit};

let byte = Byte::from_unit(1555f64, ByteUnit::KB).unwrap();

let result = byte.get_appropriate_unit(false).format(3);

assert_eq!(result, "1.555 MB");

Trait Implementations

Formats the value using the given formatter. Read more

Deal with the logical numeric equivalent.

Examples
extern crate byte_unit;

use byte_unit::{Byte, ByteUnit};

let byte1 = Byte::from_unit(1024f64, ByteUnit::KiB).unwrap();
let byte2 = Byte::from_unit(1024f64, ByteUnit::KiB).unwrap();

assert_eq!(byte1.get_appropriate_unit(false), byte2.get_appropriate_unit(true));
extern crate byte_unit;

use byte_unit::{Byte, ByteUnit};

let byte1 = Byte::from_unit(1024f64, ByteUnit::KiB).unwrap();
let byte2 = Byte::from_unit(1f64, ByteUnit::MiB).unwrap();

assert_eq!(byte1.get_appropriate_unit(true), byte2.get_appropriate_unit(false));
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more

Format the AdjustedByte object to string. The number of fractional digits is 2.

Examples
extern crate byte_unit;

use byte_unit::{Byte, ByteUnit};

let byte = Byte::from_unit(1500f64, ByteUnit::KB).unwrap();

let result = byte.get_appropriate_unit(false).to_string();

assert_eq!(result, "1.50 MB");

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.