-
Notifications
You must be signed in to change notification settings - Fork 354
Issue #511: refactor(rust): streamline backend to minimal API and update docs structure #515
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
rahulharpal1603
merged 4 commits into
AOSSIE-Org:main
from
codiphile:fix/cleanup-tauri-code
Sep 23, 2025
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,238 +1,26 @@ | ||
| ## API Documentation | ||
|
|
||
| The Rust backend provides the following commands that can be invoked from the frontend: | ||
| The Rust backend provides the following command that can be invoked from the frontend: | ||
|
|
||
| ### 1. get_folders_with_images | ||
|
|
||
| - **Description**: Retrieves folders containing images from a specified directory. | ||
| - **Parameters**: | ||
| - `directory`: String | ||
| - **Returns**: `Vec<PathBuf>` | ||
|
|
||
| ### 2. get_images_in_folder | ||
|
|
||
| - **Description**: Gets all images in a specific folder. | ||
| - **Parameters**: | ||
| - `folder_path`: String | ||
| - **Returns**: `Vec<PathBuf>` | ||
|
|
||
| ### 3. get_all_images_with_cache | ||
|
|
||
| - **Description**: Retrieves all images from multiple directories, organized by year and month, with caching. | ||
| - **Parameters**: | ||
| - `directories`: Vec<String> | ||
| - **Returns**: `Result<HashMap<u32, HashMap<u32, Vec<String>>>, String>` | ||
|
|
||
| ### 4. get_all_videos_with_cache | ||
|
|
||
| - **Description**: Retrieves all videos from multiple directories, organized by year and month, with caching. | ||
| - **Parameters**: | ||
| - `directories`: Vec<String> | ||
| - **Returns**: `Result<HashMap<u32, HashMap<u32, Vec<String>>>, String>` | ||
|
|
||
| ### 5. delete_cache | ||
|
|
||
| - **Description**: Deletes all cached data. | ||
| - **Parameters**: None | ||
| - **Returns**: `bool` | ||
|
|
||
| ### 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<u8> | ||
| - `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 | ||
| ### get_server_path | ||
|
|
||
| - **Description**: Retrieves the path to the server resources directory. | ||
| - **Parameters**: *None* | ||
| - **Returns**: `Result<String, String>` | ||
| ### 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<bool, String>` | ||
|
|
||
| ### 12. get_secure_media | ||
|
|
||
| - **Description**: Retrieves all media files from the secure folder. | ||
| - **Parameters**: | ||
| - `password`: String | ||
| - **Returns**: `Result<Vec<SecureMedia>, 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<bool, String>` | ||
|
|
||
| ### 15. get_random_memories | ||
|
|
||
| - **Description**: Retrieves random memory images from specified directories. | ||
| - **Parameters**: | ||
| - `directories`: Vec<String> | ||
| - `count`: usize | ||
| - **Returns**: `Result<Vec<MemoryImage>, 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<Utc>, | ||
| } | ||
| ``` | ||
|
|
||
| ## Usage Examples | ||
|
|
||
| ```javascript | ||
| // In your frontend JavaScript/TypeScript code: | ||
| import { invoke } from "@tauri-apps/api/tauri"; | ||
|
|
||
| // Example: Get all images with cache from multiple directories | ||
| const imagesData = await invoke("get_all_images_with_cache", { | ||
| 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"); | ||
| // Example: Get server path | ||
| const serverPath = await invoke("get_server_path"); | ||
| console.log("Server path:", serverPath); | ||
| ``` | ||
|
|
||
| ## Key Components | ||
|
|
||
| - **FileService**: Handles file system operations for images and videos. | ||
| - **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 | ||
| The API provides cross-platform support using Tauri's unified `AppHandle.path().resolve(..., BaseDirectory::Resource)` for path resolution across Windows, macOS, and Linux. | ||
|
|
||
| This backend architecture provides efficient file management, caching capabilities, secure storage, image processing, and system integration, enhancing the overall functionality of the Tauri application. | ||
| This backend provides essential path resolution functionality for the Tauri application. | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.