Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: ThirdPartyDataref, for datarefs that might not be loaded yet #23

Open
JDeeth opened this issue Dec 5, 2024 · 1 comment
Open

Comments

@JDeeth
Copy link
Contributor

JDeeth commented Dec 5, 2024

The plugins I write are often to enhance an existing aircraft and work that aircraft's custom datarefs. As such they're not guaranteed to be loaded as my plugin might be loaded first.

I've written a ThirdPartyDataref class here: https://github.com/JDeeth/nb_bn2_tweaks/blob/c8284ad96a6457c783a94372b2f92f680fdf2835/src/dataref_command.rs#L10-L50

enum ThirdPartyDataref {
    NotFound(String),
    Found(DataRef<u32, ReadWrite>),
}

It starts off as NotFound and holds the name of the dataref it should connect to. When trying to get/set the dataref, a NotFound will first search for the dataref and transform itself into a Found if successful.

Would something like this be worth polishing up and moving upstream into this crate?

(I tried to genericise it beyond <u32, ReadWrite> but ran into inexplicable errors that went beyond my limited Rust skills..!)

@samcrow
Copy link
Owner

samcrow commented Dec 7, 2024

Yes, that sounds useful.

If you can include generic type variables for the data type and access in your enum, but implement the functions for u32 ReadWrite only, that will make it easy to fill in the rest later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants