macro_rules! include_data {
($file:expr) => { ... };
}Expand description
Include data from a file as static data in the executable, of a type that
implements bytemuck::AnyBitPattern.
Can assign to both static and const variables.
A compiler error will be thrown if the source file is not the same size as
the target type. The path is interpreted by core::include_bytes and is
host-platform-specific. The interpretation of multi-byte sequences (e.g.,
a u32 which occupies 4 bytes) is according to the endianness of the target
platform.
§Example
const MY_INTEGER: i32 = include_data!("../tests/test_data/file_exactly_4_bytes_long");
static FOUR_BYTES: [u8; 4] = include_data!("../tests/test_data/file_exactly_4_bytes_long");§Safety
This macro is safe. However, if used on a custom type, that type must
implement bytemuck::AnyBitPattern. Implementing that trait has very
strict safety requirements which must be observed.