refactor: use zerocopy instead of bincode#38
Conversation
983ec68 to
6c46635
Compare
|
I forgot to add the file. Please re-approve. |
|
There seems to be an issue with your code using the PhantomData struct from the |
6c46635 to
974bbe6
Compare
|
Should be good to merge. I'd like to take a better look at it before merging tho, so I will probably merge this during the coming weekend. |
|
I found a way to integrate |
|
Nice to see that bitflags can be used with zerocopy.
Yes,
|
|
I think we are done here. I would like to get rid of the |
|
I'm not sure if the 19e4581 broke big endian targets, because the ordering in the bitfield attribute ( |
|
If you are talking about the |
|
zerocopy does not do any endian conversion, except when using a I would like to have this crate working on big endian targets, but if it's currently broken, you can of course merge this PR as-is and then I may make a big endian fix PR in the future. |
|
I have found a way how to ensure the correct endianness of bitfields with some extra By the way, LFN with UTF-16 seem to work fine. The endianness conversion is in https://github.com/Oakchris1955/simple-fatfs/blob/9bf0dccf30ac93d467995095c69eb0326d8c9b17/src/fat/direntry/ser_de.rs (line 59 for reading and line 110 for writing). I think that this PR can be merged now. I have an additional change to replace the unsafe code with zerocopy, but I think this should be a future PR. |
|
Before I merge,
Could you open an issue about big-endian tests and describe the process which you use to emulate a big endian target? Best case I'd like to run the tests on a big-endian Github Actions workflow, worst case locally on my machine. |
|
@lukaslihotzki I'd like to thank you for your contribution. If you find any other issues with |
I think that the zerocopy library is a good fit to replace bincode (#33). Benefits:
zerocopy::transmute!even checks the size during compile time. For slices, compile-time size checks are impossible. In this case, indexing (such as[..BPBFAT_SIZE]) was used before, panicking on too small slices. To preserve that panic behavior, I used.unwrap()with zerocopy. (Too small size is the only reason whyread_from_prefixor similar would return the error variant.)zerocopy::transmute!compiles to a no-op, andread_from_prefixonly does the size check.Challenges:
Bitfieldwrapper type that does the conversion. Having zerocopy support in bitfields (or the other way round) would be nice, but that doesn't exist.