MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / wasm_binary_or_text

Method wasm_binary_or_text

crates/wasmtime/src/compile/code_builder.rs:134–147  ·  view source on GitHub ↗

Equivalent of [`CodeBuilder::wasm_binary`] that also accepts the WebAssembly text format. This method will configure the WebAssembly binary to be compiled. The input `wasm_bytes` may either be the wasm text format or the binary format. If the `wat` crate feature is enabled, which is enabled by default, then the text format will automatically be converted to the binary format. # Errors This meth

(
        &mut self,
        wasm_bytes: &'a [u8],
        wasm_path: Option<&'a Path>,
    )

Source from the content-addressed store, hash-verified

132 /// configured. This method will also return an error if `wasm_bytes` is the
133 /// wasm text format and the text syntax is not valid.
134 pub fn wasm_binary_or_text(
135 &mut self,
136 wasm_bytes: &'a [u8],
137 wasm_path: Option<&'a Path>,
138 ) -> Result<&mut Self> {
139 #[cfg(feature = "wat")]
140 let wasm_bytes = wat::parse_bytes(wasm_bytes).map_err(|mut e| {
141 if let Some(path) = wasm_path {
142 e.set_path(path);
143 }
144 e
145 })?;
146 self.wasm_binary(wasm_bytes, wasm_path)
147 }
148
149 /// Reads the `file` specified for the WebAssembly bytes that are going to
150 /// be compiled.

Calls 1

wasm_binaryMethod · 0.80

Tested by

no test coverage detected