deku icon indicating copy to clipboard operation
deku copied to clipboard

Reader and Writer should modify value of Option.

Open Frostie314159 opened this issue 1 year ago • 3 comments

When using a conditional field, the reader and writer functions should operate on the value of the option. And not the option itself.

Frostie314159 avatar Mar 25 '23 14:03 Frostie314159

Do you have an example of your expected behavior?

wcampbell0x2a avatar Mar 25 '23 14:03 wcampbell0x2a

Currently I'm trying to parse radiotap headers with deku. Radiotap has a fixed header and the rest of the fields are only present, if their specific bit has been set in the header. Some of these fields are bitflags, for which I've written parser functions. In my struct they are defined as Options: ``` struct header { //... #[deku( cond="present_fields.contains(IEEE80211RadiotapFields::Flags)",
reader = "read_bitflags(deku::rest)", writer = "write_bitflags(deku::output, &self.present_fields)")] flags: Option<IEEE80211RadiotapFlags>, //... }

Frostie314159 avatar Mar 25 '23 14:03 Frostie314159

I'm not sure I fully understand the question and expected behavior. Can you provide a minimal running example w/ comments which would hilight the issue?

sharksforarms avatar Mar 27 '23 13:03 sharksforarms