1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
//! # SimConnect SDK
//! SimConnect SDK in Rust.
//!
//! ## Usage
//! ```toml
//! [dependencies]
//! simconnect-sdk = { version = "0.2", features = ["derive"] }
//! ```
//!
//! ```rust,no_run
//! use simconnect_sdk::{Notification, SimConnect, SimConnectObject};
//!
//! /// A data structure that will be used to receive data from SimConnect.
//! /// See the documentation of `SimConnectObject` for more information on the arguments of the `simconnect` attribute.
//! #[derive(Debug, Clone, SimConnectObject)]
//! #[simconnect(period = "second")]
//! #[allow(dead_code)]
//! struct AirplaneData {
//! #[simconnect(name = "TITLE")]
//! title: String,
//! #[simconnect(name = "CATEGORY")]
//! category: String,
//! #[simconnect(name = "PLANE LATITUDE", unit = "degrees")]
//! lat: f64,
//! #[simconnect(name = "PLANE LONGITUDE", unit = "degrees")]
//! lon: f64,
//! #[simconnect(name = "PLANE ALTITUDE", unit = "feet")]
//! alt: f64,
//! #[simconnect(name = "SIM ON GROUND")]
//! sim_on_ground: bool,
//! }
//!
//! fn main() -> Result<(), Box<dyn std::error::Error>> {
//! let client = SimConnect::new("Receiving data example");
//!
//! match client {
//! Ok(mut client) => {
//! let mut notifications_received = 0;
//!
//! loop {
//! let notification = client.get_next_dispatch()?;
//!
//! match notification {
//! Some(Notification::Open) => {
//! println!("Connection opened.");
//!
//! // After the connection is successfully open, we register the struct
//! client.register_object::<AirplaneData>()?;
//! }
//! Some(Notification::Object(data)) => {
//! if let Ok(airplane_data) = AirplaneData::try_from(&data) {
//! println!("{airplane_data:?}");
//!
//! notifications_received += 1;
//!
//! // After we have received 10 notifications, we unregister the struct
//! if notifications_received > 10 {
//! client.unregister_object::<AirplaneData>()?;
//! println!("Subscription stopped.");
//! break;
//! }
//! }
//! }
//! _ => (),
//! }
//!
//! // sleep for about a frame to reduce CPU usage
//! std::thread::sleep(std::time::Duration::from_millis(16));
//! }
//! }
//! Err(e) => {
//! println!("Error: {e:?}")
//! }
//! }
//!
//! Ok(())
//! }
//! ```
//!
//! See [more examples](https://github.com/mihai-dinculescu/simconnect-sdk-rs/tree/main/examples).
pub use ;
pub use *;
pub use SimConnectError;
pub use fixed_c_str_to_string;
pub use SimConnect;
pub use SimConnectObjectExt;
extern crate simconnect_sdk_derive;
pub use *;