use anyhow::{anyhow, Result};
#[doc(hidden)]
pub const ENTRIES_VERSION: u32 = 1;
#[doc(hidden)]
pub const fn assert_entries_version(generated_for: u32) {
if generated_for != ENTRIES_VERSION {
panic!(
"installrs ENTRIES schema mismatch: the installrs CLI that \
generated this crate emits version A, but the runtime \
linked here is version B. Reinstall the matching CLI \
(`cargo install installrs --version =<runtime-version>`) \
or rebuild the installer crate with the matching CLI."
);
}
}
#[doc(hidden)]
pub fn verify_payload(blobs: &[&[u8]], uninstaller_data: &[u8], expected: &[u8; 32]) -> Result<()> {
use sha2::{Digest, Sha256};
let mut h = Sha256::new();
for b in blobs {
h.update(b);
}
h.update(uninstaller_data);
let got: [u8; 32] = h.finalize().into();
if &got != expected {
return Err(anyhow!(
"installer payload integrity check failed — the file may be corrupt or tampered with"
));
}
Ok(())
}
#[doc(hidden)]
pub enum EmbeddedEntry {
File {
source_path_hash: u64,
data: &'static [u8],
compression: &'static str,
},
Dir {
source_path_hash: u64,
children: &'static [DirChild],
},
}
#[doc(hidden)]
pub struct DirChild {
pub name: &'static str,
pub kind: DirChildKind,
}
#[doc(hidden)]
pub enum DirChildKind {
File {
data: &'static [u8],
compression: &'static str,
},
Dir {
children: &'static [DirChild],
},
}