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

Method read_cwasm

src/commands/objdump.rs:406–418  ·  view source on GitHub ↗

Helper to read the input bytes of the `*.cwasm` handling stdin automatically.

(&self)

Source from the content-addressed store, hash-verified

404 /// Helper to read the input bytes of the `*.cwasm` handling stdin
405 /// automatically.
406 fn read_cwasm(&self) -> Result<Vec<u8>> {
407 if let Some(path) = &self.cwasm {
408 if path != Path::new("-") {
409 return std::fs::read(path).with_context(|| format!("failed to read {path:?}"));
410 }
411 }
412
413 let mut stdin = Vec::new();
414 std::io::stdin()
415 .read_to_end(&mut stdin)
416 .context("failed to read stdin")?;
417 Ok(stdin)
418 }
419}
420
421#[derive(clap::ValueEnum, Clone, Copy, PartialEq, Eq)]

Callers 1

executeMethod · 0.80

Calls 6

OkFunction · 0.85
with_contextMethod · 0.80
newFunction · 0.50
readFunction · 0.50
stdinFunction · 0.50
contextMethod · 0.45

Tested by

no test coverage detected