diff --git a/crates/wasmi/src/module/mod.rs b/crates/wasmi/src/module/mod.rs index 4733cb4703..028dbc8ad3 100644 --- a/crates/wasmi/src/module/mod.rs +++ b/crates/wasmi/src/module/mod.rs @@ -201,7 +201,9 @@ impl Module { /// /// # Note /// - /// This parses, validates and translates the buffered Wasm bytecode. + /// - This parses, validates and translates the buffered Wasm bytecode. + /// - The `wasm` may be encoded as WebAssembly binary (`.wasm`) or as + /// WebAssembly text format (`.wat`). /// /// # Errors /// @@ -211,7 +213,10 @@ impl Module { /// - If Wasmi cannot translate the Wasm bytecode. /// /// [`Config`]: crate::Config - pub fn new(engine: &Engine, wasm: &[u8]) -> Result { + pub fn new(engine: &Engine, wasm: impl AsRef<[u8]>) -> Result { + let wasm = wasm.as_ref(); + #[cfg(feature = "wat")] + let wasm = &wat::parse_bytes(wasm)?[..]; ModuleParser::new(engine).parse_buffered(wasm) }