Struct measurements::data::Data
source · [−]pub struct Data { /* private fields */ }
Expand description
The Data
struct can be used to deal with computer information in a common way.
Common legacy and SI units are supported.
Example
use measurements::Data;
let file_size = Data::from_mebioctets(2.5);
let octets = file_size.as_octets();
println!("There are {} octets in that file.", octets);
Implementations
sourceimpl Data
impl Data
sourcepub fn from_octets(octets: f64) -> Self
pub fn from_octets(octets: f64) -> Self
Create new Data from floating point value in Octets
sourcepub fn from_kilooctets(kilooctets: f64) -> Self
pub fn from_kilooctets(kilooctets: f64) -> Self
Create new Data from floating point value in Kilooctets (1000 octets)
sourcepub fn from_megaoctets(megaoctets: f64) -> Self
pub fn from_megaoctets(megaoctets: f64) -> Self
Create new Data from floating point value in Megaoctets (1e6 octets)
sourcepub fn from_gigaoctets(gigaoctets: f64) -> Self
pub fn from_gigaoctets(gigaoctets: f64) -> Self
Create new Data from floating point value in Gigaoctets (1e9 octets)
sourcepub fn from_teraoctets(teraoctets: f64) -> Self
pub fn from_teraoctets(teraoctets: f64) -> Self
Create new Data from floating point value in Teraoctets (1e12 octets)
sourcepub fn from_kibioctets(kibioctets: f64) -> Self
pub fn from_kibioctets(kibioctets: f64) -> Self
Create new Data from floating point value in Kibioctets (1024 octets)
sourcepub fn from_mebioctets(mebioctets: f64) -> Self
pub fn from_mebioctets(mebioctets: f64) -> Self
Create new Data from floating point value in Mebioctets (1024**2 octets)
sourcepub fn from_gibioctets(gibioctets: f64) -> Self
pub fn from_gibioctets(gibioctets: f64) -> Self
Create new Data from floating point value in Gibioctets (1024**3 octets)
sourcepub fn from_tebioctets(tebioctets: f64) -> Self
pub fn from_tebioctets(tebioctets: f64) -> Self
Create new Data from floating point value in Tebioctets (1024**4 octets)
sourcepub fn as_kilooctets(&self) -> f64
pub fn as_kilooctets(&self) -> f64
Convert this Data to a floating point value in Kilooctets (1000 octets)
sourcepub fn as_megaoctets(&self) -> f64
pub fn as_megaoctets(&self) -> f64
Convert this Data to a floating point value in Megaoctets (1e6 octets)
sourcepub fn as_gigaoctets(&self) -> f64
pub fn as_gigaoctets(&self) -> f64
Convert this Data to a floating point value in Gigaoctets (1e9 octets)
sourcepub fn as_teraoctets(&self) -> f64
pub fn as_teraoctets(&self) -> f64
Convert this Data to a floating point value in Teraoctets (1e12 octets)
sourcepub fn as_kibioctets(&self) -> f64
pub fn as_kibioctets(&self) -> f64
Convert this Data to a floating point value in Kibioctets (1024 octets)
sourcepub fn as_mebioctets(&self) -> f64
pub fn as_mebioctets(&self) -> f64
Convert this Data to a floating point value in Mebioctets (1024**2 octets)
sourcepub fn as_gibioctets(&self) -> f64
pub fn as_gibioctets(&self) -> f64
Convert this Data to a floating point value in Gibioctets (1024**3 octets)
sourcepub fn as_tebioctets(&self) -> f64
pub fn as_tebioctets(&self) -> f64
Convert this Data to a floating point value in Tebioctets (1024**4 octets)
Trait Implementations
sourceimpl Measurement for Data
impl Measurement for Data
sourcefn as_base_units(&self) -> f64
fn as_base_units(&self) -> f64
Get this quantity in the base units
sourcefn from_base_units(units: f64) -> Self
fn from_base_units(units: f64) -> Self
Create a new quantity from the base units
sourcefn get_base_units_name(&self) -> &'static str
fn get_base_units_name(&self) -> &'static str
Return the base unit for this type, as a string. For example “kilograms” Read more
sourcefn get_appropriate_units(&self) -> (&'static str, f64)
fn get_appropriate_units(&self) -> (&'static str, f64)
Returns a string containing the most appropriate units for this quantity, and a floating point value representing this quantity in those units. Useful when, for example, a length might be in millimeters if it is very small, or kilometers when it is very large. Read more
sourceimpl PartialOrd<Data> for Data
impl PartialOrd<Data> for Data
sourcefn partial_cmp(&self, other: &Self) -> Option<Ordering>
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
impl Copy for Data
impl Eq for Data
Auto Trait Implementations
impl RefUnwindSafe for Data
impl Send for Data
impl Sync for Data
impl Unpin for Data
impl UnwindSafe for Data
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more