Skip to main content

validate_binary_content

Function validate_binary_content 

Source
pub fn validate_binary_content(data: &[u8]) -> Result<(), String>
Expand description

Validate that downloaded binary content is plausible for the current platform.

This is a lightweight sanity check — not a security guarantee — that catches obviously wrong content (e.g., an HTML error page served instead of a binary).

On macOS, the content must begin with a ZIP local-file signature (PK\x03\x04) because macOS releases are distributed as .zip archives. On Linux, the content must begin with the ELF magic bytes (\x7fELF). On Windows, the content must begin with the PE MZ header.

Returns Ok(()) if the content looks valid, or an error string with a human-readable description of what was expected vs. found.