Struct measurements::data::Data
[−]
[src]
pub struct Data { /* fields omitted */ }
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);
Methods
impl Data
[src]
pub fn from_octets(octets: f64) -> Self
[src]
Create new Data from floating point value in Octets
pub fn from_bits(bits: f64) -> Self
[src]
Create new Data from floating point value in Bits
pub fn from_kilooctets(kilooctets: f64) -> Self
[src]
Create new Data from floating point value in Kilooctets (1000 octets)
pub fn from_megaoctets(megaoctets: f64) -> Self
[src]
Create new Data from floating point value in Megaoctets (1e6 octets)
pub fn from_gigaoctets(gigaoctets: f64) -> Self
[src]
Create new Data from floating point value in Gigaoctets (1e9 octets)
pub fn from_teraoctets(teraoctets: f64) -> Self
[src]
Create new Data from floating point value in Teraoctets (1e12 octets)
pub fn from_kibioctets(kibioctets: f64) -> Self
[src]
Create new Data from floating point value in Kibioctets (1024 octets)
pub fn from_mebioctets(mebioctets: f64) -> Self
[src]
Create new Data from floating point value in Mebioctets (1024**2 octets)
pub fn from_gibioctets(gibioctets: f64) -> Self
[src]
Create new Data from floating point value in Gibioctets (1024**3 octets)
pub fn from_tebioctets(tebioctets: f64) -> Self
[src]
Create new Data from floating point value in Tebioctets (1024**4 octets)
pub fn as_octets(&self) -> f64
[src]
Convert this Data to a floating point value in Octets
pub fn as_bits(&self) -> f64
[src]
Convert this Data to a floating point value in Bits
pub fn as_kilooctets(&self) -> f64
[src]
Convert this Data to a floating point value in Kilooctets (1000 octets)
pub fn as_megaoctets(&self) -> f64
[src]
Convert this Data to a floating point value in Megaoctets (1e6 octets)
pub fn as_gigaoctets(&self) -> f64
[src]
Convert this Data to a floating point value in Gigaoctets (1e9 octets)
pub fn as_teraoctets(&self) -> f64
[src]
Convert this Data to a floating point value in Teraoctets (1e12 octets)
pub fn as_kibioctets(&self) -> f64
[src]
Convert this Data to a floating point value in Kibioctets (1024 octets)
pub fn as_mebioctets(&self) -> f64
[src]
Convert this Data to a floating point value in Mebioctets (1024**2 octets)
pub fn as_gibioctets(&self) -> f64
[src]
Convert this Data to a floating point value in Gibioctets (1024**3 octets)
pub fn as_tebioctets(&self) -> f64
[src]
Convert this Data to a floating point value in Tebioctets (1024**4 octets)
Trait Implementations
impl Copy for Data
[src]
impl Clone for Data
[src]
fn clone(&self) -> Data
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl Debug for Data
[src]
fn fmt(&self, __arg_0: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more
impl Measurement for Data
[src]
fn as_base_units(&self) -> f64
[src]
Get this quantity in the base units
fn from_base_units(units: f64) -> Self
[src]
Create a new quantity from the base units
fn get_base_units_name(&self) -> &'static str
[src]
Return the base unit for this type, as a string. For example "kilograms" Read more
fn get_appropriate_units(&self) -> (&'static str, f64)
[src]
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
fn pick_appropriate_units(
&self,
list: &[(&'static str, f64)]
) -> (&'static str, f64)
[src]
&self,
list: &[(&'static str, f64)]
) -> (&'static str, f64)
Given a list of units and their scale relative to the base unit, select the most appropriate one. Read more
impl Display for Data
[src]
fn fmt(&self, f: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more
impl Add for Data
[src]
type Output = Self
The resulting type after applying the +
operator.
fn add(self, rhs: Self) -> Self
[src]
Performs the +
operation.
impl Sub for Data
[src]
type Output = Self
The resulting type after applying the -
operator.
fn sub(self, rhs: Self) -> Self
[src]
Performs the -
operation.
impl Div<Data> for Data
[src]
type Output = f64
The resulting type after applying the /
operator.
fn div(self, rhs: Self) -> f64
[src]
Performs the /
operation.
impl Div<f64> for Data
[src]
type Output = Self
The resulting type after applying the /
operator.
fn div(self, rhs: f64) -> Self
[src]
Performs the /
operation.
impl Mul<f64> for Data
[src]
type Output = Self
The resulting type after applying the *
operator.
fn mul(self, rhs: f64) -> Self
[src]
Performs the *
operation.
impl Mul<Data> for f64
[src]
type Output = Data
The resulting type after applying the *
operator.
fn mul(self, rhs: Data) -> Data
[src]
Performs the *
operation.
impl Eq for Data
[src]
impl PartialEq for Data
[src]
fn eq(&self, other: &Self) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests for !=
.
impl PartialOrd for Data
[src]
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
[src]
This method returns an ordering between self
and other
values if one exists. Read more
fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests less than (for self
and other
) and is used by the <
operator. Read more
fn le(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more