Skip to main content

WasmHeader

Struct WasmHeader 

Source
#[repr(C)]
pub struct WasmHeader {
Show 16 fields pub wasm_magic: u32, pub header_version: u16, pub role: u8, pub target: u8, pub required_features: u16, pub export_count: u16, pub bytecode_size: u32, pub compressed_size: u32, pub compression: u8, pub min_memory_pages: u8, pub max_memory_pages: u8, pub table_count: u8, pub bytecode_hash: [u8; 32], pub bootstrap_priority: u8, pub interpreter_type: u8, pub reserved: [u8; 6],
}
Expand description

64-byte header for WASM_SEG payloads.

Follows the standard 64-byte SegmentHeader. The WASM bytecode follows immediately after this header within the segment payload.

For self-bootstrapping files, two WASM_SEGs are present:

  1. role = Interpreter — a minimal WASM interpreter (~50 KB)
  2. role = Microkernel — the RVF query engine (~5.5 KB)

The bootstrap sequence is:

  1. Host reads file, finds WASM_SEG with role = Interpreter
  2. Host loads interpreter bytecode into any available execution engine
  3. Interpreter instantiates the microkernel WASM_SEG
  4. Microkernel processes VEC_SEG, INDEX_SEG, etc.

Fields§

§wasm_magic: u32

Magic: WASM_MAGIC (0x5256574D, “RVWM”).

§header_version: u16

WasmHeader format version (currently 1).

§role: u8

Role in the bootstrap chain (see WasmRole).

§target: u8

Target platform (see WasmTarget).

§required_features: u16

Required WASM features bitfield (see WASM_FEAT_*).

§export_count: u16

Number of exports in the WASM module.

§bytecode_size: u32

Uncompressed WASM bytecode size (bytes).

§compressed_size: u32

Compressed bytecode size (0 if uncompressed).

§compression: u8

Compression algorithm (same enum as SegmentHeader).

§min_memory_pages: u8

Minimum linear memory pages required (64 KB each).

§max_memory_pages: u8

Maximum linear memory pages (0 = no limit).

§table_count: u8

Number of WASM tables.

§bytecode_hash: [u8; 32]

SHAKE-256-256 hash of uncompressed bytecode.

§bootstrap_priority: u8

Priority order for bootstrap resolution (lower = tried first). The interpreter with lowest priority is used when multiple are present.

§interpreter_type: u8

If role=Interpreter, this is the interpreter type: 0x00 = generic stack machine, 0x01 = wasm3-compatible, 0x02 = wamr-compatible, 0x03 = wasmi-compatible.

§reserved: [u8; 6]

Reserved (must be zero).

Implementations§

Source§

impl WasmHeader

Source

pub fn to_bytes(&self) -> [u8; 64]

Serialize the header to a 64-byte little-endian array.

Source

pub fn from_bytes(data: &[u8; 64]) -> Result<Self, RvfError>

Deserialize a WasmHeader from a 64-byte slice.

Trait Implementations§

Source§

impl Clone for WasmHeader

Source§

fn clone(&self) -> WasmHeader

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for WasmHeader

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Copy for WasmHeader

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.