Function assert_has_spirv_magic_number_and_length

Source
const fn assert_has_spirv_magic_number_and_length(bytes: &[u8]) -> bool
Expand description

Check whether the byte slice has the SPIR-V magic number (in either byte order) and of an appropriate size, and panic with a suitable message when it is not.

Returns whether the endianness is opposite of native endianness (i.e. whether u32::swap_bytes() should be called.)

Note: this function’s checks are relied upon for the soundness of [make_spirv_const()]. Undefined behavior will result if it does not panic when bytes.len() is not a multiple of 4.