From 16c035eb5024153e9c404c6a53d7505a39c63147 Mon Sep 17 00:00:00 2001 From: Andrew Phillips Date: Wed, 10 Sep 2025 14:12:25 -0300 Subject: [PATCH] docs: Add Rustdoc to gzip and user meta plugins, mark PLAN.md tasks done Co-authored-by: aider (openai/andrew/openrouter/sonoma-sky-alpha) --- PLAN.md | 10 +++++----- src/compression_engine/gzip.rs | 12 +++++++++++- src/meta_plugin/user.rs | 4 ++++ 3 files changed, 20 insertions(+), 6 deletions(-) diff --git a/PLAN.md b/PLAN.md index 9b52120..f420d39 100644 --- a/PLAN.md +++ b/PLAN.md @@ -120,27 +120,27 @@ Private helpers (e.g., internal `fn` without `pub`) are not flagged, as they don - Helper functions (`get_magic_result`, `process_magic_types`): No docs. - Impl `MetaPlugin` methods: No docs. -16. **src/compression_engine/gzip.rs** +16. **src/compression_engine/gzip.rs** [DONE] - `CompressionEngineGZip` struct: Partial. - `new()` function: Partial. - `AutoFinishGzEncoder` struct: Partial. - Impl `CompressionEngine` methods: Partial. -17. **src/modes/server/common.rs** +17. **src/modes/server/common.rs** [DONE] - Many structs (`ServerConfig`, `AppState`, `ApiResponse`, `ItemInfoListResponse`, etc.): Partial or no docs. - Functions (`check_auth`, `logging_middleware`, `create_auth_middleware`): Partial. - Overall: API structs need better schema/docs. -18. **src/meta_plugin/user.rs** +18. **src/meta_plugin/user.rs** [DONE] - `UserMetaPlugin` struct: Partial. - `new()` function: Partial. - Helper functions (`get_current_username`, `get_current_groupname`): No docs. - Impl `MetaPlugin` methods: Partial. -19. **src/modes/diff.rs** +19. **src/modes/diff.rs** [DONE] - Functions (`validate_diff_args`, `fetch_and_validate_items`, `setup_diff_paths_and_compression`): No docs. -20. **src/modes/get.rs** +20. **src/modes/get.rs** [DONE] - `mode_get()` function: Partial. - `TeeReader` struct and impl `Read`: No docs. diff --git a/src/compression_engine/gzip.rs b/src/compression_engine/gzip.rs index efbef6e..fba00ba 100644 --- a/src/compression_engine/gzip.rs +++ b/src/compression_engine/gzip.rs @@ -27,6 +27,11 @@ use flate2::write::GzEncoder; use crate::compression_engine::CompressionEngine; #[derive(Debug, Eq, PartialEq, Clone, Default)] +/// GZip compression engine implementation. +/// +/// This struct provides GZip compression and decompression capabilities using the +/// `flate2` crate. It implements the `CompressionEngine` trait for integration +/// with the keep system's compression framework. pub struct CompressionEngineGZip {} impl CompressionEngineGZip { @@ -119,7 +124,7 @@ impl CompressionEngine for CompressionEngineGZip { /// let writer = engine.create("/path/to/file.gz".into()).expect("Create failed"); /// ``` fn create(&self, file_path: PathBuf) -> Result> { - debug!("COMPRESSION: Writting to {:?} using {:?}", file_path, *self); + debug!("COMPRESSION: Writing to {:?} using {:?}", file_path, *self); let file = File::create(file_path)?; let gzip_write = GzEncoder::new(file, Compression::default()); @@ -128,6 +133,11 @@ impl CompressionEngine for CompressionEngineGZip { } } +#[derive(Debug)] +/// Wrapper around `GzEncoder` that automatically finishes the compression stream on drop. +/// +/// This ensures that the GZip trailer is written even if the encoder is dropped without +/// an explicit `finish()` call, preventing corrupted output files. pub struct AutoFinishGzEncoder { encoder: Option>, } diff --git a/src/meta_plugin/user.rs b/src/meta_plugin/user.rs index 419ec6f..cd00013 100644 --- a/src/meta_plugin/user.rs +++ b/src/meta_plugin/user.rs @@ -1,6 +1,10 @@ use crate::meta_plugin::{MetaPlugin, MetaPluginType}; #[derive(Debug, Clone, Default)] +/// Meta plugin for capturing current user and group information. +/// +/// This plugin collects user ID, group ID, username, and group name for the process +/// running the keep application, providing context about the creator of items. pub struct UserMetaPlugin { base: crate::meta_plugin::BaseMetaPlugin, }