Skip to content

Commit

Permalink
add .wat support to Module::new
Browse files Browse the repository at this point in the history
  • Loading branch information
Robbepop committed Dec 1, 2024
1 parent 80668f1 commit 542d970
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions crates/wasmi/src/module/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
///
Expand All @@ -211,7 +213,10 @@ impl Module {
/// - If Wasmi cannot translate the Wasm bytecode.
///
/// [`Config`]: crate::Config
pub fn new(engine: &Engine, wasm: &[u8]) -> Result<Self, Error> {
pub fn new(engine: &Engine, wasm: impl AsRef<[u8]>) -> Result<Self, Error> {
let wasm = wasm.as_ref();
#[cfg(feature = "wat")]
let wasm = &wat::parse_bytes(wasm)?[..];
ModuleParser::new(engine).parse_buffered(wasm)
}

Expand Down

0 comments on commit 542d970

Please sign in to comment.