MCPcopy Create free account
hub / github.com/explodingcamera/tinywasm / write_output_bytes

Function write_output_bytes

crates/cli/src/load.rs:44–58  ·  view source on GitHub ↗
(output: &str, bytes: &[u8], force: bool)

Source from the content-addressed store, hash-verified

42}
43
44pub fn write_output_bytes(output: &str, bytes: &[u8], force: bool) -> Result<()> {
45 if output == "-" {
46 std::io::stdout().write_all(bytes)?;
47 std::io::stdout().flush()?;
48 return Ok(());
49 }
50
51 let path = Path::new(output);
52 if path.exists() && !force {
53 bail!("output file already exists: {output}; pass --force to overwrite")
54 }
55
56 std::fs::write(path, bytes).with_context(|| format!("failed to write output file `{output}`"))?;
57 Ok(())
58}
59
60fn load_module_from_bytes(input: &str, bytes: &[u8]) -> Result<LoadedModule> {
61 if bytes.starts_with(b"TWAS") {

Callers 1

runFunction · 0.85

Calls 2

flushMethod · 0.80
write_allMethod · 0.45

Tested by

no test coverage detected