From c79e7fa761196e50407c5de18977a4f9d40445c9 Mon Sep 17 00:00:00 2001 From: omagdy7 Date: Wed, 5 Jun 2024 20:56:37 +0300 Subject: feat: Added basic handling of Content-Encoding header --- src/utils.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 src/utils.rs (limited to 'src/utils.rs') diff --git a/src/utils.rs b/src/utils.rs new file mode 100644 index 0000000..e9d2ef1 --- /dev/null +++ b/src/utils.rs @@ -0,0 +1,22 @@ +use std::fs::File; +use std::io::{self, Read, Write}; + +pub fn save_bytes_to_file(bytes: &[u8], file_path: &str) -> io::Result<()> { + let mut file = File::create(file_path)?; + file.write_all(bytes)?; + Ok(()) +} + +pub fn read_file_as_bytes(path: &str) -> io::Result> { + // Open the file in read-only mode + let mut file = File::open(path)?; + + // Create a buffer to hold the file contents + let mut buffer = Vec::new(); + + // Read the file contents into the buffer + file.read_to_end(&mut buffer)?; + + // Return the buffer + Ok(buffer) +} -- cgit v1.2.3