summaryrefslogtreecommitdiff
path: root/examples/archive.rs
diff options
context:
space:
mode:
Diffstat (limited to 'examples/archive.rs')
-rw-r--r--examples/archive.rs10
1 files changed, 5 insertions, 5 deletions
diff --git a/examples/archive.rs b/examples/archive.rs
index 7a2ebab..3f118f2 100644
--- a/examples/archive.rs
+++ b/examples/archive.rs
@@ -1,4 +1,4 @@
-use eyre::Result;
+use anyhow::Result;
use tinywasm::{Module, ModuleInstance, Store, parser::Parser};
const WASM: &str = r#"
@@ -11,13 +11,13 @@ const WASM: &str = r#"
"#;
fn main() -> Result<()> {
- let wasm = wat::parse_str(WASM).expect("Failed to parse WAT");
+ let wasm = wat::parse_str(WASM)?;
let module = Parser::default().parse_module_bytes(wasm)?;
- let twasm = module.serialize_twasm()?;
- // Now, you could e.g. write `twasm` to a file called `add.twasm`
- // and load it later in a different program.
+ // Serialize the optimized module for storage or distribution.
+ let twasm = module.serialize_twasm()?;
+ // Archived modules load without parsing Wasm again and should only come from trusted sources.
let module = Module::try_from_twasm(&twasm)?;
let mut store = Store::default();
let instance = ModuleInstance::instantiate(&mut store, &module, None)?;