use std::io::{self, BufRead, stdout, Write}; fn dump_to_bin(line: String) { let words: Vec<&str> = line.split(" ").collect(); if words.len() == 2 { let iter = words[0].split_whitespace(); let data: Vec<&str> = iter.skip(1).collect(); let hex: String = data.join(""); let bytes = hex::decode(hex).unwrap(); let u8_values: Vec = bytes.iter().map(|b| *b).collect(); stdout().write_all(&u8_values).expect("Failed to write to stdout"); } } pub fn revert_hexdump(reader: Box) { for buf in reader.lines() { match buf { Ok(line) => { dump_to_bin(line) } Err(_) => { eprintln!("Cannot read input file") } } } }