From 23fbf0abd8f1452cea4339948b863065cfbae54d Mon Sep 17 00:00:00 2001 From: Aditya30ag Date: Thu, 3 Jul 2025 18:02:26 +0530 Subject: [PATCH 1/2] docs: Update Tauri/Rust API documentation to match current codebase Fixes #358 - Change Tauri/Rust docs to match the current state of the repository - Updated outdated API documentation in docs/backend/backend_rust/api.md - Added 13 missing Tauri commands that were not documented: * share_file - File system integration * save_edited_image - Image processing with filters * get_server_path - Server resources path * move_to_secure_folder - Encrypted file storage * create_secure_folder - Secure folder creation * unlock_secure_folder - Secure folder authentication * get_secure_media - Secure media retrieval * remove_from_secure_folder - Secure file removal * check_secure_folder_status - Secure folder status * get_random_memories - Random memory images * open_folder - System folder operations * open_with - System 'Open With' dialog * set_wallpaper - Desktop wallpaper setting - Fixed parameter types for existing commands: * get_all_images_with_cache: directory -> directories (Vec) * get_all_videos_with_cache: directory -> directories (Vec) - Added comprehensive documentation sections: * Data structures (SecureMedia, MemoryImage) * Enhanced usage examples for all commands * Security features section explaining AES-256-GCM encryption * Cross-platform support information * Updated key components description The documentation now accurately reflects all 18 available Tauri commands instead of the previous 5, making it much easier for developers to understand and use the complete API. --- docs/backend/backend_rust/api.md | 195 +++++++++++++++++++++++++++++-- 1 file changed, 187 insertions(+), 8 deletions(-) diff --git a/docs/backend/backend_rust/api.md b/docs/backend/backend_rust/api.md index b6fc19bfb..94833beb9 100644 --- a/docs/backend/backend_rust/api.md +++ b/docs/backend/backend_rust/api.md @@ -18,16 +18,16 @@ The Rust backend provides the following commands that can be invoked from the fr ### 3. get_all_images_with_cache -- **Description**: Retrieves all images, organized by year and month, with caching. +- **Description**: Retrieves all images from multiple directories, organized by year and month, with caching. - **Parameters**: - - `directory`: String + - `directories`: Vec - **Returns**: `Result>>, String>` ### 4. get_all_videos_with_cache -- **Description**: Retrieves all videos, organized by year and month, with caching. +- **Description**: Retrieves all videos from multiple directories, organized by year and month, with caching. - **Parameters**: - - `directory`: String + - `directories`: Vec - **Returns**: `Result>>, String>` ### 5. delete_cache @@ -36,17 +36,177 @@ The Rust backend provides the following commands that can be invoked from the fr - **Parameters**: None - **Returns**: `bool` -## Usage Example +### 6. share_file + +- **Description**: Opens the file in the system's default file manager and selects it. +- **Parameters**: + - `path`: String +- **Returns**: `Result<(), String>` + +### 7. save_edited_image + +- **Description**: Saves an edited image with applied filters and adjustments. +- **Parameters**: + - `image_data`: Vec + - `save_path`: String + - `filter`: String + - `brightness`: i32 + - `contrast`: i32 + - `vibrance`: i32 + - `exposure`: i32 + - `temperature`: i32 + - `sharpness`: i32 + - `vignette`: i32 + - `highlights`: i32 +- **Returns**: `Result<(), String>` + +### 8. get_server_path + +- **Description**: Retrieves the path to the server resources directory. +- **Parameters**: + - `handle`: tauri::AppHandle +- **Returns**: `Result` + +### 9. move_to_secure_folder + +- **Description**: Moves a file to the secure folder with encryption. +- **Parameters**: + - `path`: String + - `password`: String +- **Returns**: `Result<(), String>` + +### 10. create_secure_folder + +- **Description**: Creates a new secure folder with password protection. +- **Parameters**: + - `password`: String +- **Returns**: `Result<(), String>` + +### 11. unlock_secure_folder + +- **Description**: Unlocks the secure folder with the provided password. +- **Parameters**: + - `password`: String +- **Returns**: `Result` + +### 12. get_secure_media + +- **Description**: Retrieves all media files from the secure folder. +- **Parameters**: + - `password`: String +- **Returns**: `Result, String>` + +### 13. remove_from_secure_folder + +- **Description**: Removes a file from the secure folder. +- **Parameters**: + - `file_name`: String + - `password`: String +- **Returns**: `Result<(), String>` + +### 14. check_secure_folder_status + +- **Description**: Checks if the secure folder is set up. +- **Parameters**: None +- **Returns**: `Result` + +### 15. get_random_memories + +- **Description**: Retrieves random memory images from specified directories. +- **Parameters**: + - `directories`: Vec + - `count`: usize +- **Returns**: `Result, String>` + +### 16. open_folder + +- **Description**: Opens the parent folder of the specified file path. +- **Parameters**: + - `path`: String +- **Returns**: `Result<(), String>` + +### 17. open_with + +- **Description**: Opens a file with the system's "Open With" dialog. +- **Parameters**: + - `path`: String +- **Returns**: `Result<(), String>` + +### 18. set_wallpaper + +- **Description**: Sets an image as the desktop wallpaper. +- **Parameters**: + - `path`: String +- **Returns**: `Result<(), String>` + +## Data Structures + +### SecureMedia + +```rust +pub struct SecureMedia { + pub id: String, + pub url: String, + pub path: String, +} +``` + +### MemoryImage + +```rust +pub struct MemoryImage { + path: String, + created_at: DateTime, +} +``` + +## Usage Examples ```javascript // In your frontend JavaScript/TypeScript code: import { invoke } from "@tauri-apps/api/tauri"; -// Example: Get all images with cache +// Example: Get all images with cache from multiple directories const imagesData = await invoke("get_all_images_with_cache", { - directory: "/path/to/images", + directories: ["/path/to/images1", "/path/to/images2"], +}); + +// Example: Share a file +await invoke("share_file", { path: "/path/to/file.jpg" }); + +// Example: Save edited image +await invoke("save_edited_image", { + image_data: imageBytes, + save_path: "/path/to/save/edited.jpg", + filter: "grayscale(100%)", + brightness: 10, + contrast: 20, + vibrance: 15, + exposure: 5, + temperature: 0, + sharpness: 10, + vignette: 0, + highlights: 0 +}); + +// Example: Create secure folder +await invoke("create_secure_folder", { password: "mySecurePassword" }); + +// Example: Move file to secure folder +await invoke("move_to_secure_folder", { + path: "/path/to/file.jpg", + password: "mySecurePassword" +}); + +// Example: Get random memories +const memories = await invoke("get_random_memories", { + directories: ["/path/to/photos"], + count: 5 }); +// Example: Set wallpaper +await invoke("set_wallpaper", { path: "/path/to/wallpaper.jpg" }); + // Example: Delete cache const cacheDeleted = await invoke("delete_cache"); ``` @@ -57,5 +217,24 @@ const cacheDeleted = await invoke("delete_cache"); - **CacheService**: Manages caching of folders, images, and videos. - **FileRepository**: Interacts directly with the file system to retrieve file information. - **CacheRepository**: Handles reading from and writing to cache files. +- **Secure Storage**: Provides encrypted storage functionality with password protection. +- **Image Processing**: Handles image editing operations including filters, brightness, contrast, and other adjustments. +- **System Integration**: Provides integration with the operating system for file operations, wallpaper setting, and file management. + +## Security Features + +The API includes comprehensive security features for protecting sensitive media: + +- **Encryption**: Files moved to secure folders are encrypted using AES-256-GCM +- **Password Protection**: Secure folders require password authentication +- **Salt-based Hashing**: Uses PBKDF2 with SHA-256 for password hashing +- **Secure Random**: Uses cryptographically secure random number generation + +## Cross-Platform Support + +The API provides cross-platform support for: +- **Windows**: File operations, wallpaper setting, and system integration +- **macOS**: Native file operations and AppleScript integration +- **Linux**: Support for GNOME and KDE desktop environments -This backend architecture provides efficient file management and caching capabilities, enhancing the performance of image and video retrieval operations in the Tauri application. +This backend architecture provides efficient file management, caching capabilities, secure storage, image processing, and system integration, enhancing the overall functionality of the Tauri application. From 3b510375eff821e6aa513cd872e0457182353aa4 Mon Sep 17 00:00:00 2001 From: Rahul Harpal <51887323+rahulharpal1603@users.noreply.github.com> Date: Thu, 3 Jul 2025 22:41:16 +0530 Subject: [PATCH 2/2] Update docs/backend/backend_rust/api.md Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- docs/backend/backend_rust/api.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/docs/backend/backend_rust/api.md b/docs/backend/backend_rust/api.md index 94833beb9..011620b25 100644 --- a/docs/backend/backend_rust/api.md +++ b/docs/backend/backend_rust/api.md @@ -63,10 +63,8 @@ The Rust backend provides the following commands that can be invoked from the fr ### 8. get_server_path - **Description**: Retrieves the path to the server resources directory. -- **Parameters**: - - `handle`: tauri::AppHandle +- **Parameters**: *None* - **Returns**: `Result` - ### 9. move_to_secure_folder - **Description**: Moves a file to the secure folder with encryption.