Enum ecu_diagnostics::obd2::ObdUnitType
source · pub enum ObdUnitType {
Raw(f32),
Speed(Speed),
Percent(f32),
Temperature(Temperature),
Rpm(u32),
Volts(f32),
Time(Time),
Distance(Distance),
Pressure(Pressure),
Encoded(ObdEnumValue),
ByteArray(Vec<u8>),
}
Expand description
OBD unit type wrapper
Variants§
Raw(f32)
Raw number
Speed(Speed)
Speed value
Percent(f32)
Percentage value
Temperature(Temperature)
Temperature value
Rpm(u32)
RPM value
Volts(f32)
Volts value
Time(Time)
Time value
Distance(Distance)
Distance value
Pressure(Pressure)
Pressure value
Encoded(ObdEnumValue)
Encoded enumeration value
ByteArray(Vec<u8>)
Byte array (Bit encoding)
Implementations§
source§impl ObdUnitType
impl ObdUnitType
sourcepub fn to_metric_string(&self) -> String
pub fn to_metric_string(&self) -> String
Returns an output string with formatted value in metric form.
Values are displayed as follows:
- Raw - To 1 decimal place
- RPM - As is
- Speed - In km/h
- Percent - As percentage with 1 decimal place
- Temperature - As degrees celsius
- Volts - As is
- Time - As HH:mm:ss
- Distance - As kilometers
- Pressure - As bar
- Encoded - As is
sourcepub fn to_imperial_string(&self) -> String
pub fn to_imperial_string(&self) -> String
Returns an output string with formatted value in imperial form.
Values are displayed as follows:
- Raw - To 1 decimal place
- RPM - As is
- Speed - In miles per hour
- Percent - As percentage with 1 decimal place
- Temperature - As degrees fahrenheit
- Volts - As is
- Time - As HH:mm:ss
- Distance - As miles
- Pressure - As PSI
- Encoded - As is
sourcepub fn get_imperial_unit(&self) -> Option<&'static str>
pub fn get_imperial_unit(&self) -> Option<&'static str>
Returns the string of the units for the encoded value (If present) for imperial measurement
Units are as follows (If not specified, there is no unit attached) Speed - mph Percent - % RPM - Rpm Temperature - *F Volts - V Distance - miles Pressure - psi
sourcepub fn get_metric_unit(&self) -> Option<&'static str>
pub fn get_metric_unit(&self) -> Option<&'static str>
Returns the string of the units for the encoded value (If present) for metric measurement
Units are as follows (If not specified, there is no unit attached) Speed - km/h Percent - % RPM - Rpm Temperature - *C Volts - V Distance - km Pressure - bar
sourcepub fn as_imperial(&self) -> f32
pub fn as_imperial(&self) -> f32
Returns the raw value as a float in imperial form.
NOTE: encoded enum values are returned as their integer representation! Byte array is simply returned as the sum of all the values in the byte array
Trait Implementations§
source§impl Clone for ObdUnitType
impl Clone for ObdUnitType
source§fn clone(&self) -> ObdUnitType
fn clone(&self) -> ObdUnitType
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for ObdUnitType
impl Debug for ObdUnitType
source§impl Display for ObdUnitType
impl Display for ObdUnitType
source§impl PartialEq for ObdUnitType
impl PartialEq for ObdUnitType
source§fn eq(&self, other: &ObdUnitType) -> bool
fn eq(&self, other: &ObdUnitType) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl PartialOrd for ObdUnitType
impl PartialOrd for ObdUnitType
source§fn partial_cmp(&self, other: &ObdUnitType) -> Option<Ordering>
fn partial_cmp(&self, other: &ObdUnitType) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more