#byte #aligned #alignment #include-bytes #align #macro #embed

include_bytes_aligned

A simple macro that embeds the bytes of an external file into the executable and guarantees that they are aligned

5 releases

0.1.4 Aug 21, 2024
0.1.3 Feb 9, 2024
0.1.2 Jul 15, 2021
0.1.1 Jul 15, 2021
0.1.0 Jul 15, 2021

#79 in Memory management

Download history 502/week @ 2024-10-20 501/week @ 2024-10-27 398/week @ 2024-11-03 2210/week @ 2024-11-10 1263/week @ 2024-11-17 1044/week @ 2024-11-24 2006/week @ 2024-12-01 1664/week @ 2024-12-08 1703/week @ 2024-12-15 505/week @ 2024-12-22 624/week @ 2024-12-29 1307/week @ 2025-01-05 1614/week @ 2025-01-12 2655/week @ 2025-01-19 3225/week @ 2025-01-26 3434/week @ 2025-02-02

10,991 downloads per month
Used in 6 crates (5 directly)

MIT license

4KB

include_bytes_aligned Crates.io docs.rs

A simple macro that embeds the bytes of an external file into the executable and guarantees that they are aligned.

Usage

include_bytes_aligned!(ALIGNMENT, PATH)

Where ALIGNMENT is any integer literal (must be a power of 2), and PATH is a string literal path to the file to include, just as in include_bytes!.

Examples

use include_bytes_aligned::include_bytes_aligned;

// Aligns the data to 16 bytes
static DATA: &'static [u8] = include_bytes_aligned!(16, "path/to/file.txt");

Efficiency

This macro does not copy the bytes or duplicate them. Takes up the same amount of space in memory as the usual include_bytes!.

No runtime deps