Macro static_include_bytes

Source
macro_rules! static_include_bytes {
    ($(#[$m:meta])* $name:ident = $path:expr) => { ... };
}
Expand description

Inserts a static byte array definition with both its content and length loaded from a file at compile time. static_include_bytes!(#[attr] NAME = PATH) is semantically equivalent to #[attr] static NAME: [u8; _] = *include_bytes!(PATH); which you cannot write directly as of 2023-08-18 due to https://github.com/rust-lang/rust/issues/85077 .

ยงExample

use static_include_bytes::static_include_bytes;

static_include_bytes!(#[no_mangle] TEN_BYTES = concat!(env!("CARGO_MANIFEST_DIR"), "/ten_bytes.bin"));

assert_eq!(TEN_BYTES.len(), 10);
assert_eq!(&TEN_BYTES, b"0123456789");