Struct measurements::voltage::Voltage
source · [−]pub struct Voltage { /* private fields */ }
Expand description
The Voltage
struct can be used to deal with electric potential difference
in a common way.
Example
use measurements::Voltage;
let volts = Voltage::from_millivolts(1500.0);
let m_v = volts.as_millivolts();
let k_v = volts.as_kilovolts();
println!("A 1.5 V battery has {} mV or {} kV", m_v, k_v);
Implementations
sourceimpl Voltage
impl Voltage
sourcepub fn from_volts(volts: f64) -> Self
pub fn from_volts(volts: f64) -> Self
Create a new Voltage from a floating point value in Volts
sourcepub fn from_microvolts(microvolts: f64) -> Self
pub fn from_microvolts(microvolts: f64) -> Self
Create a new Voltage from a floating point value in Microvolts
sourcepub fn from_millivolts(millivolts: f64) -> Self
pub fn from_millivolts(millivolts: f64) -> Self
Create a new Voltage from a floating point value in Millivolts
sourcepub fn from_kilovolts(kilovolts: f64) -> Self
pub fn from_kilovolts(kilovolts: f64) -> Self
Create a new Voltage from a floating point value in Kilovolts
sourcepub fn as_microvolts(&self) -> f64
pub fn as_microvolts(&self) -> f64
Convert this Voltage into a floating point value in Microvolts
sourcepub fn as_millivolts(&self) -> f64
pub fn as_millivolts(&self) -> f64
Convert this Voltage into a floating point value in Millivolts
sourcepub fn as_kilovolts(&self) -> f64
pub fn as_kilovolts(&self) -> f64
Convert this Voltage into a floating point value in Kilovolts
Trait Implementations
sourceimpl Div<Resistance> for Voltage
impl Div<Resistance> for Voltage
sourceimpl Measurement for Voltage
impl Measurement for Voltage
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<Voltage> for Voltage
impl PartialOrd<Voltage> for Voltage
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 Voltage
impl Eq for Voltage
Auto Trait Implementations
impl RefUnwindSafe for Voltage
impl Send for Voltage
impl Sync for Voltage
impl Unpin for Voltage
impl UnwindSafe for Voltage
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