[][src]Enum iracing::telemetry::Value

pub enum Value {
    CHAR(u8),
    BOOL(bool),
    INT(i32),
    BITS(u32),
    FLOAT(f32),
    DOUBLE(f64),
    UNKNOWN(()),
    IntVec(Vec<i32>),
    FloatVec(Vec<f32>),
    BoolVec(Vec<bool>),
}

Telemetry Value

Represents a single value in the telemetry. Telemetry data is always quantitive but may be of varying numeric types, plus boolean.

The iRacing Telemetry documentation describes the data-type expected for a given telemetry measurement. Into can be used when the expected data type is known, else match can be used to dynamically handle the returned data type.

Examples

Known, Expected Data Type

use iracing::telemetry::Sample;
 
let s: Sample = some_sample_getter();
 
let gear: i32 = s.get("Gear").unwrap().into();

Unknown data type

use iracing::telemtry::{Sample, Value};
 
let v: &'static str = some_input_for_var_name();
let s: Sample = some_sample_getter();
 
match s.get(v) {
    None => println!("Didn't find that value");
    Some(value) => match {
        Value::CHAR(c) => println!("Value: {:x}", c),
        Value::BOOL(b) => println!("Yes") if b,
        Value::INT(i) => println!("Value: {}", i),
        Value::BITS(u) => println!("Value: 0x{:32b}", u),
        Value::FLOAT(f) | Value::DOUBLE(f) => println!("Value: {:.2}", f),
        _  => println!("Unknown Value")
    }
};  

Variants

CHAR(u8)
BOOL(bool)
INT(i32)
BITS(u32)
FLOAT(f32)
DOUBLE(f64)
UNKNOWN(())
IntVec(Vec<i32>)
FloatVec(Vec<f32>)
BoolVec(Vec<bool>)

Methods

impl Value[src]

pub fn size(&self) -> usize[src]

Trait Implementations

impl Clone for Value[src]

impl Debug for Value[src]

impl<'de> Deserialize<'de> for Value[src]

impl From<i32> for Value[src]

impl Into<Vec<bool>> for Value[src]

impl Into<bool> for Value[src]

impl Serialize for Value[src]

impl TryInto<f32> for Value[src]

type Error = &'static str

The type returned in the event of a conversion error.

impl TryInto<f64> for Value[src]

type Error = &'static str

The type returned in the event of a conversion error.

impl TryInto<i32> for Value[src]

type Error = &'static str

The type returned in the event of a conversion error.

impl TryInto<u32> for Value[src]

type Error = &'static str

The type returned in the event of a conversion error.

Auto Trait Implementations

impl RefUnwindSafe for Value

impl Send for Value

impl Sync for Value

impl Unpin for Value

impl UnwindSafe for Value

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: Deserialize<'de>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.