MCPcopy Create free account
hub / github.com/PerroEngine/Perro / load_static_binary

Function load_static_binary

perro_source/io_stack/perro_io/src/asset_io.rs:529–537  ·  view source on GitHub ↗
(path: &str)

Source from the content-addressed store, hash-verified

527/// builds hand back the embedded slice instead of copying it.
528pub 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.
537pub 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.

Callers 1

load_assetFunction · 0.85

Calls 3

as_refMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected