Helper to read the input bytes of the `*.cwasm` handling stdin automatically.
(&self)
| 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)] |