#byte #aligned #alignment

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

#92 in Memory management

Download history 917/week @ 2024-06-27 1195/week @ 2024-07-04 967/week @ 2024-07-11 1195/week @ 2024-07-18 1235/week @ 2024-07-25 1115/week @ 2024-08-01 785/week @ 2024-08-08 938/week @ 2024-08-15 829/week @ 2024-08-22 609/week @ 2024-08-29 936/week @ 2024-09-05 492/week @ 2024-09-12 889/week @ 2024-09-19 659/week @ 2024-09-26 618/week @ 2024-10-03 608/week @ 2024-10-10

2,897 downloads per month
Used in 5 crates (4 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