#include-bytes #aligned #align #bytes #macro

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

#85 in Memory management

Download history 806/week @ 2023-11-02 852/week @ 2023-11-09 1265/week @ 2023-11-16 717/week @ 2023-11-23 1513/week @ 2023-11-30 1403/week @ 2023-12-07 2043/week @ 2023-12-14 1020/week @ 2023-12-21 1225/week @ 2023-12-28 1004/week @ 2024-01-04 693/week @ 2024-01-11 929/week @ 2024-01-18 1059/week @ 2024-01-25 751/week @ 2024-02-01 1290/week @ 2024-02-08 1016/week @ 2024-02-15

4,283 downloads per month
Used in 2 crates

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