Skip to main content

validate_wasm_bytes

Function validate_wasm_bytes 

Source
pub fn validate_wasm_bytes(bytes: &[u8]) -> Result<(), ExecutionError>
Expand description

Validate that the bytes represent a valid WASM binary module.

Checks the magic number (\0asm) and minimum size. This is a structural validation — it does not verify the module’s internal consistency or exported functions.

§Example

use adk_code::validate_wasm_bytes;

// Valid WASM magic + version 1
let valid = b"\0asm\x01\x00\x00\x00";
assert!(validate_wasm_bytes(valid).is_ok());

// Too short
assert!(validate_wasm_bytes(b"\0asm").is_err());

// Wrong magic
assert!(validate_wasm_bytes(b"not_wasm_at_all!").is_err());