I've taken your code as an inspiration to write my own ACC bindings, here is my code:
pub fn close(&self) {
match self.handle { // my naming for your mapping variable
Some(v) => {
let succ = unsafe { CloseHandle(v) };
if succ != 0 {
println!("Handle closed succesfully");
} else {
let errno: i32 = unsafe { GetLastError() as i32 };
let message = std::io::Error::from_raw_os_error(errno);
println!("Failed to close handle: {}", message);
}
},
None => {
println!("No handle opened. Skipping.");
}
}
}
So, I called my references handle in place of your mapping and view in place of your location. If I call CloseHandle on self.view (your location) is errors with Failed to close handle: The handle is invalid. (os error 6) but if I call it on self.handle (your mapping) exits successfully.
I'm new to Rust so feel free to disregard as an actual issue, but shouldn't CloseHandle be executed on
mapping
instead ofview
? https://github.com/LeoAdamek/iracing.rs/blob/9c10904f3f17adf53685e932f02fe731a240f60a/src/telemetry.rs#L751I've taken your code as an inspiration to write my own ACC bindings, here is my code:
So, I called my references
handle
in place of yourmapping
andview
in place of your location. If I call CloseHandle on self.view (your location) is errors withFailed to close handle: The handle is invalid. (os error 6)
but if I call it on self.handle (yourmapping
) exits successfully.