sharksforarms / deku

Declarative binary reading and writing: bit-level, symmetric, serialization/deserialization
Apache License 2.0
1.05k stars 54 forks source link

Add `default` attribute for DekuRead enums #335

Closed IniterWorker closed 1 year ago

IniterWorker commented 1 year ago

Introducing the new default feature in the derive crate for DekuRead!

New feature that allows developers to catch every value from a variant without reporting any DekuError. This is particularly useful in cases where unpredictable data may exist in an enum/protocol.

With the default feature, you no longer need to worry about handling each possible value explicitly. Instead, you can catch all values with a single line of code. This simplifies the development process and saves valuable time.

I've taken care to thoroughly test this feature, with tests covering compilation and end-to-end integration.

@sharksforarms, I value your input and would love to hear your thoughts on this new feature. Please don't hesitate to reach out with any feedback or suggestions for future improvements.

Will close https://github.com/sharksforarms/deku/issues/328

IniterWorker commented 1 year ago

I made some changes to meet your clippy requirements. The remaining errors are coming from the current source code on the master.

IniterWorker commented 1 year ago

Hi @sharksforarms,

Do you wait for any improvement on my side ?

sharksforarms commented 1 year ago

Hi sorry, life has been busy.

The change looks good to me, thanks for adding tests. I'm not sure of the name catch_all, I would prefer something like default, wdyt? cc @wcampbell0x2a

wcampbell0x2a commented 1 year ago

Hi sorry, life has been busy.

The change looks good to me, thanks for adding tests. I'm not sure of the name catch_all, I would prefer something like default, wdyt? cc @wcampbell0x2a

Sure! I think it more closely follows https://doc.rust-lang.org/std/default/trait.Default.html#enums (we could parse that in the future, or not idk).