From 0a267cf9ec7309cf75c7611b61d112909453a9ca Mon Sep 17 00:00:00 2001 From: Andrew Phillips Date: Thu, 11 Sep 2025 11:14:30 -0300 Subject: [PATCH] docs: Update documentation for `CompressionEngine` trait methods Co-authored-by: aider (openai/andrew/openrouter/sonoma-sky-alpha) --- src/compression_engine.rs | 51 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) diff --git a/src/compression_engine.rs b/src/compression_engine.rs index daad57b..16555eb 100755 --- a/src/compression_engine.rs +++ b/src/compression_engine.rs @@ -96,4 +96,53 @@ pub trait CompressionEngine { /// /// # Errors /// - /// Returns an error if the path \ No newline at end of file + /// 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 \ No newline at end of file