#alignment #include-bytes #byte #macro

include_bytes_aligned

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

6 releases

0.2.0 Dec 3, 2025
0.1.4 Aug 21, 2024
0.1.3 Feb 9, 2024
0.1.2 Jul 15, 2021

#78 in Memory management

Download history 19123/week @ 2025-10-31 10385/week @ 2025-11-07 8170/week @ 2025-11-14 10391/week @ 2025-11-21 12336/week @ 2025-11-28 12841/week @ 2025-12-05 17086/week @ 2025-12-12 9927/week @ 2025-12-19 4488/week @ 2025-12-26 13359/week @ 2026-01-02 14997/week @ 2026-01-09 14526/week @ 2026-01-16 18936/week @ 2026-01-23 14369/week @ 2026-01-30 15347/week @ 2026-02-06 13189/week @ 2026-02-13

65,363 downloads per month
Used in 47 crates (9 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