Hey, I’m trying to port some C code where almost all function attributes are
void pointers. The thing is that for example, it generates a struct that has some data in it, and then it sends it through USB as a byte stream. I have solved most of these cases by generating an actual byte array and copying values into it using
ByteOrder, since I’d like to keep using safe code as far as possible.
What is troubling me is that in one moment it uses a [u32; 256] array and it passes the array to a function accepting
void * data. The function I use to represent that uses
&mut [u8], which works well with most of my data (and uses the same data type as the libusb calls).
The question is, how do I pass a
&mut [u32] to a function that accepts
&mut [u8]? Is there a good (and safe, if possible) way to do it? I cannot cast it, since it gives me a non-scalar cast. All the
u32 words have been checked for endianness (I use
.to_le() with all of them), so It shouldn’t be unsafe, I think, but I cannot extract the bytes from a