Add Nissan API support. Introduce CarApi trait to abstract API functionality
Hi @guidog,
I'm trying to integrate the Nissan API support in phosh-ev.
I gave a shot at implementing a CarApi
trait to make the Uvo and Nc API play together without duplicating the code.
I found some roadblocks, in particular I'm really stuck on this error related to the api
field of PevWindow
:
error[E0277]: `std::cell::OnceCell<Api>` cannot be shared between threads safely
--> src/window/imp.rs:308:29
|
308 | gio::spawn_blocking(move || {
| _________-------------------_^
| | |
| | required by a bound introduced by this call
309 | | let (platform, auth) = parse_ini();
310 | | let api: Box<Api> = match platform {
311 | | Platform::Uvo => Box::new(Api::Uvo(simple_uvo::UvoApi{})),
... |
319 | | sender.send(Ok("")).expect("Could not send");
320 | | });
| |_________^ `std::cell::OnceCell<Api>` cannot be shared between threads safely
I am also puzzled on the best way to call the CarApi trait functions without using a match on every function call to distinguish UvoApi from NcApi.
I am still learning Rust, feel free to give me suggestions