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

include_bytes_aligned

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

4 releases

0.1.3 Feb 9, 2024
0.1.2 Jul 15, 2021
0.1.1 Jul 15, 2021
0.1.0 Jul 15, 2021

#90 in Memory management

Download history 882/week @ 2024-03-14 1050/week @ 2024-03-21 976/week @ 2024-03-28 1018/week @ 2024-04-04 1239/week @ 2024-04-11 709/week @ 2024-04-18 847/week @ 2024-04-25 849/week @ 2024-05-02 555/week @ 2024-05-09 1102/week @ 2024-05-16 884/week @ 2024-05-23 1200/week @ 2024-05-30 1368/week @ 2024-06-06 1333/week @ 2024-06-13 1201/week @ 2024-06-20 772/week @ 2024-06-27

4,783 downloads per month
Used in 4 crates (3 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