Open pizzart opened 1 year ago
from what I can see, this would first require adding serde
support to arbitrary-int
.
are we looking for Deserialize
support here as well? I think we can just deserialize to a temporary struct and then use the Struct::new()
.
@pizzart if you're up to it, you can try building this. We can skip over serde
support in arbitrary-int
by just saving as the underlying type, or you could add that support as well (should be easy).
I have a rough draft of this at https://github.com/widberg/bilge using https://github.com/danlehmann/arbitrary-int/pull/38. It doesn't play nice with padding
and reserved
fields yet. I think these fields should not be serialized so I will probably skip them like the generated new
implementation. Some cleanup is also in order.
@widberg nicely done, feel free to open a draft PR :)
I was waiting for the arbitrary-int pr to go through so I wouldn't have my git repo as a dependency but I'll open a draft pr so it's easier to find and update it later.
The arbitrary-int PR looks like it was merged and released as part of v1.2.7, is there more work that needs to be done to revive this feature? This would be very nice to have, specifically the serialize side of things.
I switched the Cargo.toml dependency from my arbitrary-int git repo to v1.2.7 on crates.io and switched the PR from draft to open. My tests are passing but please test my repo and let me know if there are any problems.
@dicta you might know a bit more about serde than me, take a look at the code in #84. Or even try it with your usecase via git repo dependency. I will merge it soon.
I've been testing this today and it's working well so far for my usecase -- which is just using SerializeBits, not the deserialize side.
Features I'm currently exercising are:
csv
and serde_json
crates, ensuring that field names are handledreserved
memberImportant features I haven't yet looked at so can't comment on status:
#[bitsize(N)]
where N is an arbitrary-int
type, not a standard-width integerreserved
members in a single bitfield
The normal Serialize macro serializes the struct into a struct with the field "value":
Feature request: add a derive macro implementing Serialize on the struct and its fields behind a
serde
feature flag, something like:so that it serializes to: