1pub use hara_wasm::core::Value;
7pub use hara_wasm::vm::{
8 decode_program, disassemble, execute_program, execute_program_with_globals, prepare_call,
9 validate, FunctionId, FunctionPrototype, Instruction, Machine, PreparedCall, Program,
10 ValidationError, VmError, VmFiber, VmFiberState, VmOutcome,
11};
12
13use std::rc::Rc;
14
15pub fn load(bytes: &[u8]) -> Result<Rc<Program>, String> {
16 decode_program(bytes).map(Rc::new)
17}
18
19pub fn execute(bytes: &[u8]) -> Result<Value, String> {
20 let program = load(bytes)?;
21 execute_program(program).map_err(|error| error.to_string())
22}
23
24#[cfg(test)]
25mod tests {
26 use super::*;
27
28 #[test]
29 fn rejects_unverified_input_without_a_compiler_dependency() {
30 assert_eq!(
31 load(b"not-hbc").unwrap_err(),
32 "bytecode artifact has invalid magic"
33 );
34 }
35}