(path: &str)
| 527 | /// builds hand back the embedded slice instead of copying it. |
| 528 | pub fn load_asset(path: &str) -> io::Result<Vec<u8>> { |
| 529 | load_asset_cow(path).map(Cow::into_owned) |
| 530 | } |
| 531 | |
| 532 | /// Load an asset, borrowing embedded bytes when the build embeds them. |
| 533 | /// |
| 534 | /// Static (release) builds keep every binary asset in `.rodata`, so the copy |
| 535 | /// [`load_asset`] makes is pure waste for read-only consumers. Disk, archive |
| 536 | /// and compressed-font sources still return owned bytes. |
| 537 | pub fn load_asset_cow(path: &str) -> io::Result<Cow<'static, [u8]>> { |
| 538 | validate_virtual_asset_path(path)?; |
| 539 | // Static-binary fast path: no resolved-path String, no root Arc bump, and |
| 540 | // one lock acquisition instead of two. |
no test coverage detected