Expand description
§use-wasm-binary
WebAssembly binary format primitives for RustUse. This crate checks magic bytes and version bytes without parsing full Wasm binaries.
§Example
use use_wasm_binary::{looks_like_wasm_binary, validate_wasm_header};
let bytes = b"\0asm\x01\0\0\0";
let header = validate_wasm_header(bytes).expect("valid header");
assert!(looks_like_wasm_binary(bytes));
assert_eq!(header.version(), 1);§Scope
- Magic bytes, version bytes, and minimal header validation.
- Helpers for byte slices that look like Wasm binaries.
§Non-goals
- No full binary decoding.
- No validation beyond the header.
§License
Licensed under either of the following, at your option:
- Apache License, Version 2.0
- MIT license
Structs§
- Wasm
Binary Header - Minimal WebAssembly binary header metadata.
Enums§
- Wasm
Binary Error - Error returned when a WebAssembly binary header is not recognized.
- Wasm
Binary Format - Coarse WebAssembly binary format marker.
Constants§
- WASM_
BINARY_ HEADER_ LEN - The byte length of a minimal WebAssembly binary header.
- WASM_
MAGIC_ BYTES - WebAssembly binary magic bytes: ‘\0asm’.
- WASM_
VERSION_ 1_ BYTES - WebAssembly version 1 encoded as little-endian bytes.
Functions§
- has_
wasm_ magic - Returns ‘true’ when the byte slice starts with the WebAssembly magic bytes.
- looks_
like_ wasm_ binary - Returns ‘true’ when the byte slice has the magic bytes and version-1 header.
- parse_
wasm_ binary_ header - Parses a minimal WebAssembly binary header.
- validate_
wasm_ binary_ header - Validates a minimal WebAssembly binary header.
- validate_
wasm_ header - Validates a minimal WebAssembly binary header.