Hey everyone!
I am trying to rewrite a C project in Rust by rethinking every aspect of it. It's not a second system syndrome issue though, as I am doing this to improve my Rust coding by learning how to think in Rust itself.
And in this effort I have found and interesting situation where I am not quite sure how to treat those void pointers data. Look at this code:
// Image type, bpp always RGBA (32bit)
// NOTE: Data stored in CPU memory (RAM)
typedef struct Image {
void *data; // Image raw data
int width; // Image base width
int height; // Image base height
int mipmaps; // Mipmap levels, 1 by default
int format; // Data format (PixelFormat type)
} Image;
// Wave type, defines audio wave data
typedef struct Wave {
unsigned int sampleCount; // Total number of samples
unsigned int sampleRate; // Frequency (samples per second)
unsigned int sampleSize; // Bit depth (bits per sample): 8, 16, 32 (24 not supported)
unsigned int channels; // Number of channels (1-mono, 2-stereo)
void *data; // Buffer data pointer
} Wave;
typedef struct Music {
AudioStream stream; // Audio stream
unsigned int sampleCount; // Total number of samples
bool looping; // Music looping enable
int ctxType; // Type of music context (audio filetype)
void *ctxData; // Audio context data, depends on type
} Music;
I wonder what would be the safest, 'no FFI' and best performant solution to deal with cases like that