danlehmann / arbitrary-int

A modern and lightweight implementation of arbitrary integers for Rust
MIT License
31 stars 12 forks source link

Add serde support #38

Closed widberg closed 11 months ago

widberg commented 11 months ago

Basic Serialize and Deserialize implementations for UInt<T, BITS> with graceful error handling and tests, gated by serde feature. A step towards closing https://github.com/hecatia-elegua/bilge/issues/74.

hecatia-elegua commented 11 months ago

looks solid, but does serde not have some kind of error so we would not need InvalidUIntValueError? (I have not looked into it)

danlehmann commented 11 months ago

Apologies for the slow response! (I originally got this patch while I was on vacation and lost track of it when I returned).

But apologies aside, I've been trying to find a reviewer this morning (as I don't really know serde) - I'd like to merge this asap. If no one is willing to do it, I'll have to read up a bit on serde

widberg commented 11 months ago

looks solid, but does serde not have some kind of error so we would not need InvalidUIntValueError? (I have not looked into it)

If you can find a way to make Serde's Unexpected take a 128-bit int I'd be happy to do that, but as far as I can see it only takes a 64-bit int. This is because 128-bit support in Serde came later and changing the API now would require a bump in the major version number. The InvalidUIntValueError was my solution to this but I'm open to ideas :)

hecatia-elegua commented 11 months ago

@widberg oh sorry, you have commented that in code. I think it's a good solution :)

danlehmann commented 11 months ago

I'll enable the github tests in a follow-up