-
-
Notifications
You must be signed in to change notification settings - Fork 75
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
bitflags!
support
#307
Comments
I think the simplest way to do this (in terms of additional API surface) would be to add a That macro would then use some internal magic to also generate an efficient |
Ah, this is going to be much more difficult to implement efficiently since bitflags can be arbitrary constants, but a proc macro can't access the final value. |
Removing from the milestone as I don't think this will happen in 0.3 |
I still really want this, since nicely-formatted bitflags are incredibly useful. I think one possible way to support this would be to create a defmt::bitflags! {
pub struct Flags: u8 {
const LE_LIMITED_DISCOVERABLE = 1 << 0;
const LE_GENERAL_DISCOVERABLE = 1 << 1;
}
} This would create 2 additional statics initialized to The decoder would then read the static's initializers out of the binary (which is somewhat tricky, and not something we currently do, but should be implementable), and essentially run The runtime encoding of |
Currently, using
#[derive(Format)]
on abitflags!
-generated type results in output that looks likeBitflags { bits: 3564356 }
, which isn't very readable.It would be nice if defmt offered a convenient way to format bitflags the same way as the generated
Debug
implementation. Doing this efficiently probably requires adding first-class support for bitflags.The text was updated successfully, but these errors were encountered: