[−][src]Struct zeus_fm::zeuslib::utils::fs::filesize::FileSize
The size of a file, consisting of counts for data units.
Fields
pb: u16
Pebibytes (250 bytes) component of the file size
tb: u16
Tebibytes (240 bytes) component of the file size
gb: u16
Gibibytes (230 bytes) component of the file size
mb: u16
Mebibytes (220 bytes) component of the file size
kb: u16
Kibibytes (210 bytes) component of the file size
b: u16
Bytes component of the file size
Implementations
impl FileSize
[src]
pub fn from_total_bytes(total_bytes: u64) -> Self
[src]
Returns a new FileSize
with representing given number of bytes
This produces a FileSize
with optimal values for each count
field. In other words, the largest possible units are filled
first, rather than just setting the bytes field to the input.
Arguments
total_bytes
- The number of bytes the newFileSize
should represent
Examples
use zeus_fm::zeuslib::utils::fs::FileSize; const b: u64 = 1048726; let fs = FileSize::from_total_bytes(b); assert_eq!(fs.pb, 0); assert_eq!(fs.tb, 0); assert_eq!(fs.gb, 0); assert_eq!(fs.mb, 1); assert_eq!(fs.kb, 0); assert_eq!(fs.b, 150);
pub fn get_total_bytes(&self) -> u64
[src]
Get the total number of bytes in this FileSize
Examples
use zeus_fm::zeuslib::utils::fs::FileSize; const b: u64 = 1048576; let fsize = FileSize::from_total_bytes(b); // Create a `FileSize` let total_bytes = fsize.get_total_bytes(); // Get the total number of bytes assert_eq!(total_bytes, b);
pub fn get_fractional_pb(&self) -> f64
[src]
Get the total number of Pebibytes (250 bytes) this FileSize
represents as a
floating-point number.
pub fn get_fractional_tb(&self) -> f64
[src]
Get the total number of Tebibytes (240 bytes) this FileSize
represents as a
floating-point number.
pub fn get_fractional_gb(&self) -> f64
[src]
Get the total number of Gibibytes (230 bytes) this FileSize
represents as a
floating-point number.
pub fn get_fractional_mb(&self) -> f64
[src]
Get the total number of Mebibytes (220 bytes) this FileSize
represents as a
floating-point number.
pub fn get_fractional_kb(&self) -> f64
[src]
Get the total number of Kibibytes (210 bytes) this FileSize
represents as a
floating-point number.
Trait Implementations
impl Clone for FileSize
[src]
impl Debug for FileSize
[src]
impl Display for FileSize
[src]
impl Eq for FileSize
[src]
impl Ord for FileSize
[src]
fn cmp(&self, other: &Self) -> Ordering
[src]
#[must_use]fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn clamp(self, min: Self, max: Self) -> Self
[src]
impl PartialEq<FileSize> for FileSize
[src]
impl PartialOrd<FileSize> for FileSize
[src]
Auto Trait Implementations
impl RefUnwindSafe for FileSize
impl Send for FileSize
impl Sync for FileSize
impl Unpin for FileSize
impl UnwindSafe for FileSize
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,