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

source

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
source

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
source

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

source

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

source

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

source

pub fn as_metric(&self) -> f32

Returns the raw value as a float in metric 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

source§

fn clone(&self) -> ObdUnitType

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for ObdUnitType

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Display for ObdUnitType

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl PartialEq for ObdUnitType

source§

fn eq(&self, other: &ObdUnitType) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd for ObdUnitType

source§

fn partial_cmp(&self, other: &ObdUnitType) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

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 · source§

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
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl StructuralPartialEq for ObdUnitType

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.