Skip to content
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

BREAKING CHANGE - Enhance Python bindings plus streaming decryption support, improve chunk handling, add comprehensive tests #395

Merged
merged 3 commits into from
Dec 17, 2024

Conversation

dirvine
Copy link
Member

@dirvine dirvine commented Nov 17, 2024

🚨 Breaking Changes

This PR includes several commits that packages each change in a more reviewable chunk of changes. Please go commit by commit to follow this one. The large issues are clean up of API, removing unused and confusing parts, remove old streaming functionality and introduce a newer and small decrypt streaming facility with the ability to retrieve chunks is parallel. There may Abe further small tweaks to confirm data.

Python API Changes:
Removed 'py_' prefix from Python binding function names for a cleaner API.
Changed Python module structure to use _self_encryption as the internal module name.

✨ Features

Python Binding Enhancements
Comprehensive Bindings:
Implemented Python bindings for all core functionalities.
Restructured Python package to follow best practices.
Fixed naming conflicts between Rust and Python modules.
Improved package structure and dependency management.
Streaming Decryption Support:
Added streaming decryption functionality with parallel chunk retrieval.
Implemented streaming decryption in Python bindings.
Added examples and documentation for streaming operations.
Type Hints and Documentation:
Added proper type hints and docstrings to all Python functions and classes.
Improved function documentation and type annotations.
Updated README with comprehensive Python usage examples.
Chunk Handling Improvements
Enhanced encrypt_from_file:
Modified to store all chunks, including parent chunks.
Improved Decryption Functions:
Updated decrypt functions to handle parent chunks correctly using efficient HashMap lookups.
Fixed decrypt_full_set to use efficient chunk retrieval.
DataMap Enhancements:
Improved DataMap functionality with better child handling.
Added serialization/deserialization functions to the public API.

🧪 Testing Enhancements

Comprehensive Test Suite:
Added tests covering all combinations of encryption and decryption methods:
In-memory encryption → All decryption methods.
File-based encryption → All decryption methods.
Streaming decryption with parallel chunk retrieval.
Added tests for large file handling and data map shrinking.
Verified cross-platform compatibility.
Fixed Test Failures:
Resolved issues in StreamSelfDecryptor tests.
Ensured decrypted content is available at the expected output path.
Improved Error Handling in Tests:
Added detailed debug output for better diagnostics.
Enhanced error handling tests to match actual behavior.

🔨 Refactoring

Stream Module:
Moved stream-related methods to a separate src/stream.rs file.
Extracted stream structs and implementations for better readability.
Utility Functions:
Moved non-public utility functions from lib.rs to utils.rs.
Added pub(crate) visibility to utility functions.
API Simplification:
Removed unused seek_info related code to simplify the public API.
Renamed and restricted visibility of internal functions for proper encapsulation.
Renamed decrypt to decrypt_sorted_set.
Changed visibility from pub to pub(crate).

🗃️ Build System

Python Packaging:
Updated pyproject.toml for better package management.
Fixed maturin configuration for proper module naming.
Added proper dependencies in setup.py.

📚 Documentation

User Guides and Examples:
Updated README with comprehensive Python usage examples.
Added detailed API documentation for Python bindings.
Developer Documentation:
Improved implementation details section.
Added examples for streaming operations.

🛠️ General Improvements

Error Handling:
Improved error messages and handling across the codebase.
Used std::io::Error with appropriate ErrorKind in StreamSelfDecryptor.
Code Cleanup:
Resolved linter warnings and performed code cleanup.
Ensured consistent use of file paths and error handling.
Organized code logically and added helpful comments.

📝 Impact

These changes provide a more robust, well-tested, and user-friendly interface for both Rust and Python users. The enhancements enable efficient handling of large files through streaming operations and improve the reliability of chunk handling. Refactoring efforts have resulted in cleaner code, better maintainability, and enforced proper encapsulation, reducing maintenance burden and simplifying the API surface.

✅ Checklist

[x] Added tests that cover all major use cases and edge conditions.
[x] Ensured backward compatibility where possible.
[x] Updated documentation accordingly.
[x] Verified cross-platform compatibility.

Short description

Enhance Python bindings with streaming decryption support, improve chunk handling, add comprehensive tests, and refactor codebase for better maintainability.
Footnote
Please review the breaking changes and updated APIs before integrating this PR.

@dirvine dirvine requested a review from a team as a code owner November 17, 2024 13:55
@dirvine dirvine force-pushed the master branch 4 times, most recently from 53391cb to 4cf23e8 Compare December 1, 2024 08:40
@dirvine dirvine force-pushed the master branch 2 times, most recently from 4d17333 to 8aaa6e3 Compare December 17, 2024 20:55
@dirvine dirvine enabled auto-merge (rebase) December 17, 2024 21:28
@dirvine dirvine disabled auto-merge December 17, 2024 21:28
@dirvine dirvine merged commit a9d4bae into maidsafe:master Dec 17, 2024
7 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant