docs: Update documentation for CompressionEngine trait methods

Co-authored-by: aider (openai/andrew/openrouter/sonoma-sky-alpha) <aider@aider.chat>
This commit is contained in:
Andrew Phillips
2025-09-11 11:14:30 -03:00
parent 24e66ca75a
commit 0a267cf9ec

View File

@@ -96,4 +96,53 @@ pub trait CompressionEngine {
///
/// # Errors
///
/// Returns an error if the path
/// Returns an error if the path is invalid or if there are permission issues.
fn create(&self, file_path: PathBuf) -> Result<Box<dyn Write>>;
/// 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