Skip to main content

Crate use_wasm_binary

Crate use_wasm_binary 

Source
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§

WasmBinaryHeader
Minimal WebAssembly binary header metadata.

Enums§

WasmBinaryError
Error returned when a WebAssembly binary header is not recognized.
WasmBinaryFormat
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.