To answer the obvious question, I can't use a u32 buffer because this is a wasm module and actually the buffer is a view into a JavaScript ImageData object.
This looks sound but is widely unecessary and only incidentally correct on your own platform, due to endianess of integers. Also, consider that part of the buffers will not have been written to and the length of the slice pixels might be different than simple buffer.len() / 4. You can instead achieve similar effect in safe code by iterating over chunks of 4 bytes and converting those slices to proper arrays (that is [u8; 4]). You can add manual alignment if not writing to part of the buffer was actually intended.
You can think of the compiler as copy-pasting the definition for a const at every location it is used. With a static, there will only ever be one instance of that variable in your program and every use of the static will refer to the same piece of memory.
I generally use const for magic numbers and things which are "constants". static variables are for when you need a singleton or global variable for whatever reason.
You may also want to read the relevant pages in the Rust reference (const, static).
While this is sound (because u32 allows all bit patterns and u8 has no padding) it's not what you want. Remember this note in the docs:
The method may make the middle slice the greatest length possible for a given type and input slice, but only your algorithm's performance should depend on that, not its correctness. It is permissible for all of the input data to be returned as the prefix or suffix slice.
So code that ignores the prefix and suffix can't be correct.