pub struct SimConnect<'a> { /* private fields */ }
Expand description

A SimConnect session. This provides access to data within the MSFS sim.

Implementations§

source§

impl<'a> SimConnect<'a>

source

pub fn open<F>(name: &str, callback: F) -> Result<Pin<Box<SimConnect<'a>>>>where F: FnMut(&mut SimConnect<'_>, SimConnectRecv<'_>) + 'a,

Send a request to the Microsoft Flight Simulator server to open up communications with a new client.

source

pub fn call_dispatch(&mut self) -> Result<()>

Used to process the next SimConnect message received. Only needed when not using the gauge API.

source

pub fn set_data_on_sim_object<T: DataDefinition>( &mut self, object_id: SIMCONNECT_OBJECT_ID, data: &T ) -> Result<()>

Make changes to the data properties of an object.

source

pub fn request_data_on_sim_object_type<T: DataDefinition>( &mut self, request_id: SIMCONNECT_DATA_REQUEST_ID, radius: DWORD, type: SIMCONNECT_SIMOBJECT_TYPE ) -> Result<()>

Retrieve information about simulation objects of a given type that are within a specified radius of the user’s aircraft.

source

pub fn request_data_on_sim_object<T: DataDefinition>( &mut self, request_id: SIMCONNECT_DATA_REQUEST_ID, object_id: SIMCONNECT_OBJECT_ID, period: Period ) -> Result<()>

Request when the SimConnect client is to receive data values for a specific object

source

pub fn map_client_event_to_sim_event( &mut self, event_name: &str, mask: bool ) -> Result<DWORD>

Map a Prepar3D event to a specific ID. If mask is true, the sim itself will ignore the event, and only this SimConnect instance will receive it.

source

pub fn transmit_client_event( &mut self, object_id: SIMCONNECT_OBJECT_ID, event_id: DWORD, data: DWORD ) -> Result<()>

Trigger an event, previously mapped with map_client_event_to_sim_event

source

pub fn create_client_data<T: ClientDataDefinition>( &mut self, name: &str ) -> Result<ClientDataArea<T>>

Allocate a region of memory in the sim with the given name. Other SimConnect modules can use the name to read data from this memory using request_client_data. This memory cannot be deallocated.

source

pub fn get_client_area<T: ClientDataDefinition>( &mut self, name: &str ) -> Result<ClientDataArea<T>>

Create a handle to a region of memory allocated by another module with the given name.

source

pub fn request_client_data<T: ClientDataDefinition>( &mut self, request_id: SIMCONNECT_DATA_REQUEST_ID, name: &str ) -> Result<()>

Request a pre-allocated region of memory from the sim with the given name. A module must have already used create_client_data to allocate this memory.

source

pub fn set_client_data<T: ClientDataDefinition>( &mut self, area: &ClientDataArea<T>, data: &T ) -> Result<()>

Set the data of an area acquired by create_client_data or get_client_data.

source

pub fn ai_create_non_atc_aircraft( &mut self, container_title: &str, tail_number: &str, init_position: SIMCONNECT_DATA_INITPOSITION, request_id: SIMCONNECT_DATA_REQUEST_ID ) -> Result<()>

source

pub fn ai_create_parked_atc_aircraft( &mut self, container_title: &str, tail_number: &str, icao: &str, request_id: SIMCONNECT_DATA_REQUEST_ID ) -> Result<()>

source

pub fn ai_remove_object( &mut self, object_id: SIMCONNECT_OBJECT_ID, request_id: SIMCONNECT_DATA_REQUEST_ID ) -> Result<()>

source

pub fn subscribe_to_system_event( &mut self, system_event_name: &str ) -> Result<DWORD>

source

pub fn unsubscribe_from_system_event( &mut self, event_id: SIMCONNECT_CLIENT_EVENT_ID ) -> Result<()>

source

pub fn set_system_event_state( &mut self, event_id: SIMCONNECT_CLIENT_EVENT_ID, on: bool ) -> Result<()>

Trait Implementations§

source§

impl<'a> Debug for SimConnect<'a>

source§

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

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

impl<'a> Drop for SimConnect<'a>

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for SimConnect<'a>

§

impl<'a> !Send for SimConnect<'a>

§

impl<'a> !Sync for SimConnect<'a>

§

impl<'a> Unpin for SimConnect<'a>

§

impl<'a> !UnwindSafe for SimConnect<'a>

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere 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 Twhere 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.