Session

Struct Session 

Source
pub struct Session { /* private fields */ }
Expand description

A Session is used to access data from iRacing.

The data is split between metadata about the available data, and the data itself The metadata (returned in a Var) is valid for the life of the Session. The Var can be used to get the current value for that variable out of the last read row of data.

§Safety

All the method in Session are marked as unsafe. They all ultimately interact with memory mapped data from iRacing in addition some use Win32 APIs as well.

Implementations§

Source§

impl Session

Source

pub unsafe fn connected(&self) -> bool

Is this session still connected to the iRacing data.

§Safety

see details on Session

Source

pub unsafe fn expired(&self) -> bool

Has this session expired? i.e. no longer connected to iRacing.

§Safety

see details on Session

Source

pub unsafe fn wait_for_data(&mut self, wait: Duration) -> DataUpdateResult

Waits for upto ‘wait’ amount of time for a new row of data to be available. The wait value should not exceed an u32’s worth of milliseconds, approx ~49 days

§Safety

see details on Session

Source

pub unsafe fn get_new_data(&mut self) -> DataUpdateResult

Attempt to get newer data from iRacing.

§Safety

see details on Session

Source

pub unsafe fn dump_vars(&self)

dump_vars is for diagnostics and investigation, it writes out all the variables definitions and their current value.

§Safety

see details on Session

Source

pub unsafe fn find_var(&self, name: &str) -> Option<Var>

find_var will look for an iracing data point/variable with the supplied name (case sensitive). None is returned if its unable to find a matching item. The return Var is only valid for use with the Session that created it.

§Safety

see details on Session

Source

pub unsafe fn var_value(&self, var: &Var) -> Value<'_>

return the value of the supplied variable as of the most recently fetched row of data. this will panic if you pass a Var instance generated by a different Session instance.

§Safety

see details on Session

Source

pub unsafe fn value<'a, T>(&'a self, var: &Var) -> Result<T, T::Error>
where T: TryFrom<Value<'a>, Error = Error>,

Read the value of the supplied variable, and convert it to the relevent rust type. The rust type can be a primitive such as i32,f32,f64 or one of the bitfield/enums defined in the flags package.

§Safety

see details on Session

Source

pub unsafe fn session_info_update(&self) -> i32

iRacing has a second set of data called session_info that changes at a much slower rate. session_info_update is incremented each time the session_info data is updated.

§Safety

see details on Session

Source

pub unsafe fn session_info(&self) -> String

Returns the current Session info string. This is a Yaml formatted string that you’ll need to parse.

§Safety

see details on Session

Source

pub unsafe fn broadcast_msg(&self, msg: BroadcastMsg) -> Result<(), WIN32_ERROR>

A number of things can be controlled in iRacing remotely via broadcast messages. This will send the supplied message. There is no way to determine that iRacing has actually acted on the message. Many of the messages only work when the simulator is in a specific state.

§Safety

Unlike the rest of Session, this doesn’t interact with the memory mapped data,but it does use Win32 calls to broadcast the message to iRacing.

Trait Implementations§

Source§

impl Debug for Session

Source§

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

Formats the value using the given formatter. Read more

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

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>,

Source§

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.