install_blob_env_if_unset

Function install_blob_env_if_unset 

Source
pub fn install_blob_env_if_unset(
    env_var: &str,
    name_hint: &str,
    bytes: &[u8],
) -> Result<()>
Expand description

Re-export of the blob extract / install helpers so the ktstr and cargo-ktstr binaries (separate crates linking this lib) can extract their include_bytes!-embedded blobs and export the paths at startup. The bytes live in each binary; the mechanism lives in the lib (the vmm::blobs module). Re-exported here because vmm is pub(crate), mirroring the wprof re-export above. Extract bytes via extract_blob and export its path through env_var, unless the var is already set or bytes is empty.

An already-set env_var wins (explicit override — used by tests and callers pointing ktstr at a pre-extracted blob). Empty bytes mean the blob’s build was skipped (e.g. KTSTR_SKIP_BUSYBOX_BUILD wrote a 0-byte placeholder): nothing is exported, so consumers get the clean “unset” error from the load helpers at use time rather than an opaque “exec format error” on a 0-byte blob.

Mirrors cargo-ktstr’s startup blob install for the standalone ktstr binary, which embeds its own copy of busybox and calls this from main.

§Safety

The caller MUST invoke this before spawning any thread or running any code that reads environment variables concurrently: std::env::set_var is unsound with a concurrent reader.