-
-
Notifications
You must be signed in to change notification settings - Fork 48
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
RE:Dependency Updates, Documentation Enhancements, New Features, and Code Refactoring #253
Merged
Conversation
This file contains 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
…ration - Replaced `getrandom` crate with `rand` to simplify and modernize random number generation. - Updated `gen_random_*` functions to use `rand::thread_rng().fill()` for generating random bytes of specified lengths. - Adjusted encryption functions to use `gen_random_bytes` for generating random values.
…to rows, and column_dimensions to columns - Renamed `cell_collection` to `cells` for consistency and clarity. - Renamed `row_dimensions` to `rows` for improved readability. - Renamed `column_dimensions` to `columns` for better understanding. - Updated all method calls and references accordingly.
This commit removes the `ahash` dependency and replaces its usage with the standard library's `DefaultHasher`. This change simplifies the dependency tree and reduces external dependencies while maintaining the same hashing functionality. - Removed the `ahash` crate from `Cargo.toml`. - Updated the `SharedStringItem` struct to use `std::hash::DefaultHasher` instead of `AHasher` from `ahash`.
…tion This commit refactors the random byte generation in the `gen_random_bytes` function by replacing the use of `OsRng` with `thread_rng`. This change simplifies the code and improves performance by using the thread-local random number generator. - Updated the `gen_random_bytes` function to utilize `thread_rng()` for filling the byte vector. - Removed the `OsRng` import as it is no longer needed.
This commit simplifies the test code by replacing custom hex decoding and encoding functions with the `hex-literal` crate. This change improves readability and reduces boilerplate code in the tests. - Removed `decode_hex` and `encode_hex` helper functions. - Updated test cases to use the `hex!` macro for byte literals.
This commit sorts the dependencies in `Cargo.toml` for improved readability and organization. Sorting helps maintain a consistent format and makes it easier to locate specific dependencies.
This commit removes the lint configurations from `Cargo.toml` and transfers them to `lib.rs` using attribute macros. This change centralizes lint settings within the codebase, making it easier to manage and understand the linting rules applied to the project. - Removed lint settings from `Cargo.toml`. - Added lint attributes in `lib.rs` for better backwards compatibility.
This commit refactors the code to replace the use of the `is_none_or` method with match statements. This change improves compatibility with a lower minimum supported Rust version, since `is_none_or` is only available in stable since Rust 1.82.0. - Updated `is_support` method in `TwoCellAnchor` to use match. - Refactored `_has_vertical` and `has_horizontal` methods in `MergeCells` to use match for start and end row/column checks.
This commit sets the minimum supported Rust version in `Cargo.toml` to 1.79.0, as determined by the `cargo-msrv` tool. This version is dictated by the `bitstream-io` dependency, which is a transitive dependency of the `image` crate. Setting the minimum version ensures compatibility with the required features and functionality. - Added `rust-version = "1.79.0"` to `Cargo.toml`.
This commit removes the unused `js` feature from the `[features]` section in `Cargo.toml`. The `js` feature is no longer utilized in the project, and its removal helps to maintain a cleaner configuration. Previously, this feature led to the inclusion of the `js` feature from the `getrandom` dependency, which was removed in a prior commit. - Deleted the `js` feature entry from `Cargo.toml`.
… calendar systems * add `num-traits` dependency for numeric casts * introduce `DEFAULT_TIMEZONE` constant for consistency * implement `excel_to_date_time_object` for converting Excel timestamps to `NaiveDateTime` * add `convert_date_windows_1900` and `convert_date_mac_1904` for specific calendar systems * enhance `convert_date_crate` to support both Windows 1900 and Mac 1904 systems * include detailed documentation for new functions with examples and panic behavior
…d enhance RNG security - Introduced the `generate_random_bytes!` macro to eliminate repetitive code for generating random bytes. - Replaced `rand::thread_rng` with `rand::rngs::OsRng` to utilize a cryptographically secure random number generator. - Updated cryptographic key constants to use fixed-size arrays instead of slices for improved type safety. - Enhanced error handling in random byte generation by adding `expect` messages. - Removed unused imports and commented-out code to clean up the codebase. - Improved consistency in hash function implementations and key management. This refactoring improves code maintainability, readability, and security by centralizing random byte generation and ensuring the use of secure RNG sources.
Extract multiple static variables into the `constants` module, eliminating the need to pass them as parameters in function calls. This refactor simplifies function signatures, centralizes configuration values, and enhances maintainability. Future updates may revert this approach to accommodate support for additional algorithms as the crate evolves.
…_code at crate level - Rename private methods across multiple modules by removing leading underscores to adhere to Rust naming conventions. - Additionally, add `#![allow(dead_code)]` at the crate level to silence dead code warnings.
…sheet processing - Reorganized the `make_buffer` function for better readability and maintainability. - Replaced manual iteration with `try_for_each` for processing worksheets. - Consolidated worksheet processing logic to handle both deserialized and raw data more cleanly. - Improved comments for clarity on each processing step. - Streamlined the addition of various worksheet components (charts, drawings, comments, etc.). - Ensured proper handling of printer settings and other worksheet relationships.
…tions * Add detailed parameter descriptions and return values for all public functions * Improve documentation formatting and clarity for encryption methods * Add specific documentation for AES-256-CBC implementation details * Include clippy allow attributes for possible truncation warnings * Document HMAC and IV generation processes * Add comprehensive documentation for password-to-key conversion logic
This fixes the following `clippy` warning: > multiple versions for dependency `thiserror`: 1.0.69, 2.0.8 > for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#multiple_crate_versions `thiserror` and `thiserror-impl` are transitive dependencies: ```sh cargo tree --invert --package [email protected] thiserror-impl v1.0.69 (proc-macro) └── thiserror v1.0.69 ├── html_parser v0.7.0 │ └── umya-spreadsheet v2.2.0 (/home/mxsrm/code/umya-spreadsheet) └── rav1e v0.7.1 └── ravif v0.11.11 └── image v0.25.5 └── umya-spreadsheet v2.2.0 (/home/mxsrm/code/umya-spreadsheet) cargo tree --invert --package [email protected] thiserror-impl v2.0.8 (proc-macro) └── thiserror v2.0.8 ├── pest v2.7.15 │ ├── html_parser v0.7.0 │ │ └── umya-spreadsheet v2.2.0 (/home/mxsrm/code/umya-spreadsheet) │ ├── pest_derive v2.7.15 (proc-macro) │ │ └── html_parser v0.7.0 (*) │ ├── pest_generator v2.7.15 │ │ └── pest_derive v2.7.15 (proc-macro) (*) │ └── pest_meta v2.7.15 │ └── pest_generator v2.7.15 (*) └── zip v2.2.2 └── umya-spreadsheet v2.2.0 (/home/mxsrm/code/umya-spreadsheet) ```
…lization - Refactored the `is_address` function to use `OnceLock` for lazy initialization of the regex pattern, improving performance by compiling the regex only once. - Enhanced documentation for `is_address` to clarify its parameters, return values, and potential panics. - Removed the previous implementation of `is_address` to streamline the code. - Added examples in the documentation to demonstrate usage.
- Corrected the documentation comment for `get_sheet_by_name` to fix the syntax error. - Refactored the `check_sheet_name` method to use a more concise if-else structure for clarity. - Improved readability of the code while maintaining the same functionality.
Re-enabled test cases in the helper/crypt module that were previously disabled. To ensure fidelity, results were calculated using the code at tag 2.2.1 (commit b58e16e) and verified that the new code produces the same results.
Update test vectors after changing verifier_hash_input from string to hex literal. The change ensures more accurate test data representation and fixes hash value expectations. - Convert verifier_hash_input from string to hex literal - Update encrypted_verifier_hash_input expected value - Update verifier_hash_value and encrypted_verifier_hash_value test vectors - Add print_hex debug macro for test diagnostics
…arsing - Use token! macro to simplify pushing operator tokens - Refactor parse_to_tokens logic for cleaner code structure by breaking up the 700+ lines function in smaller subfunctions
Refine the `generate_random_bytes` macro by removing unnecessary slice indexing when filling the array with random bytes.
…dia object creation - Removed `get_binary_data` function as it was only used once and replaced with a direct call to `fs::read`. - Simplified the media object creation process by removing unnecessary unwrap calls. This change reduces redundancy and makes the codebase cleaner.
* Split monolithic write function into smaller, focused functions * Add comprehensive rustdoc comments for all functions * Implement unit tests for all worksheet writing components * Add type alias for InternalWriter to improve code clarity * Improve error handling and type safety
Add version constants for crate version, major, minor, patch, and pre-release flag from Cargo.toml. - Added `src/version.rs` with various version constants. - Updated `src/lib.rs` to include the new version module and re-export its constants. We could also convert the `MAJOR`, `MINOR` and `PATCH` items to `usize` at compile time, if we raise the MSRV to 1.82.0: ```rust pub const VERSION_MAJOR: usize = match usize::from_str_radix(env!("CARGO_PKG_VERSION_MAJOR"), 10) { Ok(val) => val, Err(_) => panic!("Conversion of compile-time env 'CARGO_PKG_VERSION_MAJOR' to usize failed."), }; ```
Refactors the usage of regular expressions throughout the codebase to utilize `once_cell` for improved performance and thread safety. This replaces the previous approach of using `OnceLock` or creating new regex instances repeatedly. The change enhances efficiency by ensuring that regex compilation happens only once. A new helper function `compile_regex!` is introduced to simplify the process. This also removes unnecessary static variables. - The `once_cell` crate is added as a dependency. - The `regex` dependency is removed (we use the `fancy_regex` crate)
…ile-time Replaces the use of a `HashMap` in `NumberingFormat` with a `phf` hash map for improved performance and reduced memory consumption. This change leverages compile-time hashing provided by the `phf` crate, resulting in faster lookups and smaller binary sizes. The `OnceLock` previously used to initialize the `HashMap` is no longer needed. The `phf` crate is added as a dependency. This improves build time and runtime performance.
- Added `assert_sha256` macro for asserting SHA-256 hash equivalence. - Added `print_sha256_hex` mmacro for easy printing of SHA-256 hashes. - Move test helper macros to `helper/utils`. - Updated the `crypt` module tests to use the new `assert_sha256` macro. - Adjusted linting configurations in `lib.rs` to allow unused macros.
- Replaces the use of `once_cell::sync::OnceCell` with `std::sync::OnceLock` in `compile_regex` macro to improve compatibility and adhere to Rust's standard library practices. - Removes now unused dependency on `once_cell`. This change ensures that the codebase uses the latest and most idiomatic way to handle lazy initialization of static variables, enhancing both performance and safety.
Update the library documentation to be more informative and user-friendly. The changes include: - Improved descriptions and example code snippets for common use cases like reading/writing files, adding sheets, changing cell values, styling and inserting/removing rows/ columns. - Improved wording to enhance clarity and correct minor grammatical issues. - Added a more detailed description of the lazy reader. - Improved code example explanations. - Added doc comment links to relevant modules/structs (e.g. [Style](crate::structs::style)).
This commit introduces a new macro `pub_mod_use!` to streamline module declarations and exports in `structs.rs`. The macro replaces individual module declarations with a single macro call, reducing code duplication and improving readability: - Modules are now declared and exported using the `pub_mod_use!` macro. - Each module is made private within its own scope and then re-exported with the desired visibility. - The change reduces the number of lines significantly, from 494 to 170, enhancing maintainability. This refactoring will make it easier to manage the visibility of modules and their contents in future updates.
This commit introduces the `AttrCollection` type alias, which is a vector of `AttrPair` structs. `AttrPair` holds a key-value pair for XML attributes, where the value is a `Cow<str>`. This allows for more efficient handling of string attributes, avoiding unnecessary allocations. The commit also updates all structs to use `AttrCollection` instead of `Vec<(&str, &str)>` for XML attributes. This change improves code readability and maintainability. Additionally, the `AttrPair` struct implements `From` traits for various types, making it easier to create attribute pairs.
… update writer This commit introduces a `From` implementation for `AttrPair` to convert it into a tuple of `(&str, Cow<str>)`. This allows for seamless conversion of `AttrPair` instances into a format that `quick_xml` can handle. Additionally, the commit updates the `write_start_tag` function in `src/writer/driver.rs` to use the new `From` implementation. This change simplifies the code and makes it more efficient by avoiding manual tuple creation.
- Changed the `argb` field in the `Color` struct from `Option<String>` to `Option<ARGB8>`. - Added helper methods to convert between hex strings and ARGB8. - Updated methods to handle the new ARGB8 type, including `set_argb`, `get_argb`, and `set_attributes`. - Modified constants to use ARGB8 for predefined colors. - Enhanced the `get_argb_with_theme` method to return ARGB8 values correctly. - Added tests for hex conversion and color setting functionality.
- Modified the `Border` struct to use `Option<Box<Color>>` for the `color` field. - Updated methods to handle the optional color, including `get_color`, `set_color`, and `set_attributes`. - Adjusted the `get_hash_code` method to handle the optional color. - Updated the `write_to` method to handle the optional color. - Improved consistency in color handling within the `Border` struct. This change drastically reduce the amount of heap allocations when cloning Worksheets.
The compiler knows best which functions to inline. If the end user wants optimization, they should enable `lto = true` in their Cargo.toml. See MathNya#250 (comment)
This reverts commit dd0d524.
Support three-digit hex color codes with and without leading hash. This change addresses issues where short hex codes were not properly expanded, ensuring compatibility with CSS standards and improving user experience in color specification. - Expand three-digit hex codes by repeating each digit. - Add integration tests for both `#RGB` and `RGB` formats. - Update existing tests to reflect new behavior. See MathNya#250 (comment)
- Changed the file paths in `integration_test.rs` to reflect the actual names of the test result files for better clarity and consistency in testing procedures. - Updated paths from 'bbb_new_sheet_value.xlsx' to 'three_digit_hex_color_with_hash.xlsx' and 'three_digit_hex_color_without_hash.xlsx' for the respective integration tests.
- Changed the return type of `get_sheet_collection_mut` from `&mut Vec<Worksheet>` to `&mut [Worksheet]` to improve type safety and flexibility in how the sheets can be manipulated. - This adjustment ensures that users of the API cannot directly resize the vector, which aligns with the intended use of this method for accessing existing sheets only.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
#250