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
impl Session
Sourcepub unsafe fn wait_for_data(&mut self, wait: Duration) -> DataUpdateResult
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
Sourcepub unsafe fn get_new_data(&mut self) -> DataUpdateResult
pub unsafe fn get_new_data(&mut self) -> DataUpdateResult
Sourcepub unsafe fn dump_vars(&self)
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
Sourcepub unsafe fn find_var(&self, name: &str) -> Option<Var>
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
Sourcepub unsafe fn var_value(&self, var: &Var) -> Value<'_>
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
Sourcepub unsafe fn value<'a, T>(&'a self, var: &Var) -> Result<T, T::Error>
pub unsafe fn value<'a, T>(&'a self, var: &Var) -> Result<T, T::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
Sourcepub unsafe fn session_info_update(&self) -> i32
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
Sourcepub unsafe fn session_info(&self) -> String
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
Sourcepub unsafe fn broadcast_msg(&self, msg: BroadcastMsg) -> Result<(), WIN32_ERROR>
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.