taks / esp32-nimble

A wrapper for the ESP32 NimBLE Bluetooth stack.
Apache License 2.0
118 stars 35 forks source link

Use packedstruct instead of unsafe transmuation #10

Open dberlin opened 1 year ago

dberlin commented 1 year ago

Hey, Nice crate - i hacked it up a bit to try to make it safer.

Most (but not all) of the unsafe usage is around trying to convert various structures into various byte representations and back. Or make bitwise copies of non-Copy structures, etc.

For those cases, the packed_struct crate can be used to do it without pain or unsafe code.