From 24e66ca75ae8b232a79cb49b25bc382c052d8935 Mon Sep 17 00:00:00 2001 From: Andrew Phillips Date: Thu, 11 Sep 2025 11:10:51 -0300 Subject: [PATCH] refactor: Remove unused methods from `CompressionEngine` trait Co-authored-by: aider (openai/andrew/openrouter/sonoma-sky-alpha) --- src/compression_engine.rs | 114 +------------------------------------- 1 file changed, 1 insertion(+), 113 deletions(-) diff --git a/src/compression_engine.rs b/src/compression_engine.rs index e3ab1a5..daad57b 100755 --- a/src/compression_engine.rs +++ b/src/compression_engine.rs @@ -96,116 +96,4 @@ pub trait CompressionEngine { /// /// # Errors /// - /// Returns an error if the path is invalid or if there are permission issues. - fn create(&self, file_path: PathBuf) -> Result>; - - /// Checks if this compression engine is supported on the current system. - /// - /// Some compression types may require external programs or features to be enabled. - /// - /// # Returns - /// - /// * `bool` - True if supported, false otherwise. - fn is_supported(&self) -> bool { - true - } - - /// Checks if this compression engine is internal (built-in) or external (program-based). - /// - /// Internal engines use Rust implementations without external dependencies. - /// External engines rely on system programs. - /// - /// # Returns - /// - /// * `bool` - True if internal, false if external. - fn is_internal(&self) -> bool { - true - } - - /// Copies decompressed content from a file to a writer. - /// - /// Reads the compressed file and writes the decompressed content to the provided writer. - /// - /// # Arguments - /// - /// * `file_path` - Path to the compressed file. - /// * `writer` - Writer to receive decompressed content. - /// - /// # Returns - /// - /// * `Result<()>` - Success if the copy completes, or an error. - /// - /// # Errors - /// - /// Propagates errors from opening the file or copying data. - fn copy(&self, file_path: PathBuf, writer: &mut dyn Write) -> Result<()> { - let mut reader = self.open(file_path)?; - io::copy(&mut reader, writer)?; - writer.flush()?; - Ok(()) - } - - /// Decompresses and outputs file content to stdout. - /// - /// Convenience method to decompress and print the contents of a compressed file. - /// - /// # Arguments - /// - /// * `file_path` - Path to the compressed file. - /// - /// # Returns - /// - /// * `Result<()>` - Success if the content is output, or an error. - /// - /// # Errors - /// - /// Propagates errors from copying to stdout. - fn cat(&self, file_path: PathBuf) -> Result<()> { - let mut stdout = io::stdout().lock(); - self.copy(file_path, &mut stdout) - } - - /// Calculates the decompressed size of a file. - /// - /// Reads the entire decompressed content to determine its size in bytes. - /// - /// # Arguments - /// - /// * `file_path` - Path to the compressed file. - /// - /// # Returns - /// - /// * `Result` - The decompressed size in bytes, or an error. - /// - /// # Errors - /// - /// Returns an error if the file cannot be opened or read. - /// - /// # Examples - /// - /// ``` - /// let engine = /* some engine */; - /// let size = engine.size("file.gz".into()).unwrap(); - /// println!("Decompressed size: {} bytes", size); - /// ``` - fn size(&self, file_path: PathBuf) -> Result { - let mut reader = self.open(file_path)?; - let mut buffer = [0; libc::BUFSIZ as usize]; - let mut size: usize = 0; - - loop { - let n = reader.read(&mut buffer[..libc::BUFSIZ as usize])?; - if n == 0 { - debug!("COMPRESSION: EOF"); - break; - } - - size += n; - } - - Ok(size) - } -} - -lazy_static! { - /// Mapping of \ No newline at end of file + /// Returns an error if the path \ No newline at end of file