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::Pod.

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.

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::Pod. Implementing that trait has very struct safety requirements which must be observed.