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

Rust enums don't support combining, can't set multiple bitflags #135

Open
kidevuojarvi opened this issue Nov 14, 2022 · 3 comments
Open

Comments

@kidevuojarvi
Copy link

Some of the bitflag data in the project is stored with enums, which causes issues with flags that are not mutually exclusive. Rust doesn't support combining enumerated values, and thus prevents the use of multiple flags, even though the flags are cast into u16 in serialisation.

The specific case I ran into is mavlink::common::GimbalDeviceFlags, where I'd like to lock each axis. This requires setting three flags, which can be done with bitwise-OR in C++, but is currently impossible with the Rust implementation.

@Erk-
Copy link
Contributor

Erk- commented Nov 14, 2022

It seems the reason that it fails is because it is not listed with display = "bitmask" in the <field>events which is what is used to decide if it should be a bitflag or a enum. This could be resolved by doing it a different way or doing some patching of the files when the code is generated.

@kidevuojarvi
Copy link
Author

Ah, apparently. Thanks for the quick reply, I'll look for a workaround.

@Erk-
Copy link
Contributor

Erk- commented Nov 14, 2022

If you make a folder called patches in the build folder you can drop patches that will be applied when compiling there

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