object send+sync, probably a bad idea
Some checks failed
CI / Rust checks (push) Failing after 59s
Security / Audit (push) Successful in 24s

This commit is contained in:
2024-10-21 14:06:12 +02:00
parent 4088df3d5e
commit 6f1c647687
2 changed files with 7 additions and 4 deletions

View File

@@ -33,6 +33,9 @@ pub struct Object {
pub(crate) data_addr: *const u32, pub(crate) data_addr: *const u32,
} }
unsafe impl Send for Object {}
unsafe impl Sync for Object {}
impl Object { impl Object {
/// Try and transmute this SimConnect object as a `T` struct. /// Try and transmute this SimConnect object as a `T` struct.
/// ///

View File

@@ -31,8 +31,6 @@ fn main() -> Result<(), anyhow::Error> {
// .subscribe(SomeEvent); // .subscribe(SomeEvent);
let mut id = 0;
let ctrl_c = CtrlC::new(); let ctrl_c = CtrlC::new();
loop { loop {
@@ -41,7 +39,7 @@ fn main() -> Result<(), anyhow::Error> {
Notification::Open => { Notification::Open => {
simconnect.subscribe_to_system_event(SystemEventRequest::FlightLoaded)?; simconnect.subscribe_to_system_event(SystemEventRequest::FlightLoaded)?;
simconnect.register_object::<AtcID>()?; let id = simconnect.register_object::<AtcID>()?;
simconnect.register_object::<Fuel>()?; simconnect.register_object::<Fuel>()?;
let cs = CString::new("ITWORKS")?; let cs = CString::new("ITWORKS")?;
@@ -50,7 +48,8 @@ fn main() -> Result<(), anyhow::Error> {
buffer[i] = *b as i8; buffer[i] = *b as i8;
} }
simconnect.set_data_on_sim_object(&mut AtcID { value: buffer })?; simconnect
.set_data_on_sim_object_with_id(id, &mut AtcIDCPacked { value: buffer })?;
tracing::info!("ATC_ID set"); tracing::info!("ATC_ID set");
simconnect.set_data_on_sim_object(&mut Fuel { simconnect.set_data_on_sim_object(&mut Fuel {
@@ -78,6 +77,7 @@ fn main() -> Result<(), anyhow::Error> {
buffer[i] = *b as i8; buffer[i] = *b as i8;
} }
let id = simconnect.get_object_id::<AtcID>()?;
simconnect.set_data_on_sim_object_with_id( simconnect.set_data_on_sim_object_with_id(
id, id,
&mut AtcIDCPacked { value: buffer }, &mut AtcIDCPacked { value: buffer },