Skip to main content

FORMAT_VERSION

Constant FORMAT_VERSION 

Source
pub const FORMAT_VERSION: u32 = 2;
Expand description

The format version this crate writes and the only one it reads.

The version changes whenever the encoding or any instruction’s meaning changes; decode refuses every other version rather than guess. Version 2 (bytecode-lang 0.3) added parameter lists and call shapes to the function and import records, repacked the policy bytes for shift = saturate, and added the reference, separation, pow, abs, shaped-call, and raise instructions (specs/LSB.md §7.4).

§Examples

use bytecode_lang::{encode, ModuleBuilder, FORMAT_VERSION};

let bytes = encode(&ModuleBuilder::new().finish().unwrap());
assert_eq!(bytes[4..8], FORMAT_VERSION.to_le_bytes());
assert_eq!(FORMAT_VERSION, 2);