Add Rkyv support - #110
Conversation
|
Thanks, this looks great. Could you please setup automated tests (see e.g. #111 which does this). Happy to take it then |
|
Added the CI job and synced to main, not sure if you wanted to squash or not so I rebased -> forced the changes |
|
I did a merge from main so that tests run as they were broken on main (they're fixed now) - feel free to overwrite that with a git push -f yourself again |
|
Ok so not completely fixed, because I've asked on the Rkyv discord, I'll keep you updated when I get an answer |
|
Worked on this again: I don't think it's actually possible to remove the wrapper archival type, because Rkyv internally use rend to deal with endianness to store it's serialization format. So I'm back with where I started with the I'm really not a fan of having the unsafe pointer cast to convert from rend -> arbitrary_int. Not sure if I should also add a section with Feel free to squash if you're ok with this, or I can rebase clean if you want |
The Verify impls cast the archived value (e.g. rend's u16_le) to the native UInt/Int and range-checked the byte-swapped value on mismatched-endian hosts: valid archives were rejected and crafted out-of-range archives could pass verification. rend already provides From impls to native, so convert via T: From<T::Archived> instead of the unsafe cast, and add a multi-byte round-trip test.
|
@IzawGithub please take a look at my suggestion - this gets rid of the unsafe and fixes big-endian |
|
I've got no idea how you managed to get that Want me to clean and put you as co-author on base 209a642? |
|
When merging we'll squash, so I am happy with this PR from my end. Are there more changes you want to do make? |
|
Nope, it looks fine so you can merge iyw |
In the same vein as Serde, add Rkyv support with an optional feature.
An example (and also my) use case is for writing savestates for an emulator. Rkyv is really good at making small ser file, and combining it with arbitrary-int for type system invariant fits well.
The code seems weirdly simple too but the tests cases works fine.