valida_vm_api_linux_x86/tmpfile_helper.rs
use std::{fs, io::Write, path::Path};
use tempfile::NamedTempFile;
/// Convenience function that reads file contents as bytes. Used by the example.
pub fn read_file_bytes(path: &Path) -> std::io::Result<Vec<u8>> {
fs::read(path)
}
/// Convenience function that creates a temporary file from bytes. Used by the example.
pub fn bytes_to_temp_file(bytes: &[u8]) -> std::io::Result<NamedTempFile> {
let mut temp_file = NamedTempFile::new()?;
temp_file.write_all(bytes)?;
temp_file.flush()?;
Ok(temp_file)
}